Talk:Pointer (computing)

From Wikipedia, the free encyclopedia

This article is within the scope of WikiProject Computer science.
??? This article has not yet received a rating on the assessment scale.
??? This article has not yet received an importance rating on the assessment scale.

Contents

[edit] Old comments

Reading this page, although it's pretty much correct, I'm not terribly fond of the approach taken. It tacitly refers to C and the Intel platform throughout, worst of all in the second paragraph, with little attention given to the variety of ways of treating pointers on other platforms or in other languages that have them, most notably assembly languages.

The statement that memory capacity is limited to pointer size is misleading and ignores segmentation, as is the statement that pointer operations are more efficient than array operations.

I also think explaining the close connection between pointers and how the underlying hardware operates would emphasize how fundamental they are. I've updated the page to strike at a few of these problems. Disagreements welcome. Derrick Coetzee 18:05, 4 Jan 2004 (UTC)

Mikkalai, please do not revert my edits without explanation. I think a mention of C++ references in the introduction is paragraph is completely out of place — I merely moved it, not destroyed it. On top of this, you reverted a perfectly good change lower down seemingly without noticing at all. I've added a statement to the intro now that I hope we can both agree on. Derrick Coetzee 05:59, 21 Sep 2004 (UTC)

You removed my perfectly valid warning about what constitutes trouble for 89% of beginner programmers, and I removed your vague and repetitive phrase about "simpler form of...". Simpler in what sense? Mikkalai 06:35, 21 Sep 2004 (UTC)
I moved your warning, not removed it. References are "simpler" in the sense that they're formally easier to reason about, because they can't do as many operations. Perhaps more restricted or less powerful is more descriptive. If you believe this confusion is a big deal, I'll leave these changes alone, but please explain yourself in the future, at least in the edit comment box, or I'm left thinking you just reverted my changes for no reason when I had a reason for doing them. Derrick Coetzee 07:32, 21 Sep 2004 (UTC)

I (Beliavsky) have added a discussion of pointers in Fortran, based on a comp.lang.fortran Usenet message by Walt Brainerd, in a thread entitled "Fortran article in Wikipedia".

I would like to known about Pointer in JAVA language.

There are no pointers in Java. See reference (computer science). Deco 01:16, 10 January 2006 (UTC)

[edit] Edits

Removed "cannot be circular" (in reference to the Haskell List implementation) because that is simply false. See this page: http://haskell.org/hawiki/TyingTheKnot You can easily make these types of lists circular in Haskell. In fact the Haskell Prelude includes a function called cycle to do that. See the function cycle in the Prelude here: http://www.haskell.org/onlinereport/standard-prelude.html

Removed "A potential advantage of the C version is that it allows for values of heterogeneous types." because it doesn't make a whole lot of sense. In order to put values of heterogeneous type in the C version you're going to need to tag your values with their types... something which Haskell supports directly and with type safety, and which C most definitely does not, so how exactly is this an advantage of the C version? 71.68.70.236 15:54, 8 January 2006 (UTC)

What I meant by "cannot be circular" was that it can't accidentally be circular; it's rather hard to accidentally give a ciruclar definition, but in the presence of mutation, accidental circularity is more of a problem. I'll clarify; you're right. Is "cannot be accidentally circular" okay?
As for heterogeneous types, various invariants could exist that would allow code to predict the types of values in a heterogeneous list. Or, with tagged structures, the tags can be part of the value rather than the list itself. I think it's better to simply call it out as a "potential" benefit. How about "A potential advantage of the C version is that it can be heterogeneously typed and used ad hoc." --Mgreenbe 21:27, 8 January 2006 (UTC)

The "accidentally circular" thing sounds better, although I'm not sure it's actually strictly true (if it's possible to do it, it's possible to do it accidentally). Maybe rather than "cannot be..." anything, just "easier to reason about" or "easier to avoid unwanted circularity" or something along those lines. I guess you're right about the C heterogenously typed thing - I didn't even think about using invariants without tagging values. Although note that in Haskell you can certainly include the tags as part of the value rather than part of the list; in fact that is the idiomatic way to do it. 71.68.70.236 01:00, 10 January 2006 (UTC)

Haskell doesn't have pointers. This issue is relevant to references in general, not pointers in particular - let's keep any related info there. Thanks. Deco 01:13, 10 January 2006 (UTC)

[edit] Good C/C++ pointer style

When it comes to programming style, I can't decide what the best way is to define and later use pointers:

int* myintptr;
int *myintptr;
int * myintptr;

While it is more of a cosmetical question, I'm still looking for the ultimate reason to prefer one style. What whould you say is best to use? --Abdull 14:57, 2 March 2006 (UTC)

I'd say int *myptr;, because that makes the association clearest in multiple-variable declarations, such as int *isapointer, notapointer;. —donhalcon 15:42, 2 March 2006 (UTC)

I think it's just a matter of choice: I prefer int* isapointer because it makes clear that the variable is a pointer to an int. That way, I'd force myself to declare non-pointer variables in a separate line, reducing the possibility of mistakes and making it easy to see what is what just by looking at the first word on its declaration (int* versus int, int&, int**, int&*, etc.) Habbit 18:24, 2 March 2006 (UTC)

Yeah, so a lot of it comes down to the really fundamental problem, which is that C/C++ variable declarations consider pointer-ness to be part of the declarator rather than the type. —donhalcon 18:33, 2 March 2006 (UTC)

[edit] Wild pointers

Too much code! It looks like a training manual. Alex 20:58, 28 March 2006 (UTC)

[edit] Second thoughts on move

Most of Wikipedia's link to pointer mean a "data pointer", so was my move wrong? I thought it might be nice to let dog lovers have their word back. Also, a lot of teachers still use a long stick to actually "point" to a spot on the blackboard. ^_^ --Uncle Ed 15:38, 17 November 2006 (UTC)

Your move has created the confusing situation where a (category) page is the target of a redirect from the page without the category, and there's a double redirect to boot. Shouldn't this have gone to WP:RM? I'd put it there now, if I was sure what to say. --Tardis 21:05, 17 November 2006 (UTC)