Re: segfault w/ block, but not file scope



Richard Heathfield <invalid@xxxxxxxxxxxxxxx> writes:
> Keith Thompson said:
>> Then we need to make it very clear to J Random Newbie that C doesn't
>> support pass by reference as a languag construct.
>
> Right.
>
>> Don't say that the
>> "*" means pass by reference; say that the "*" means you're passing a
>> pointer value, which can be used to do the equivalent of pass by
>> reference.
>
> To a newbie, the two statements can seem equivalent, especially if he
> doesn't know what "pass by reference" is and has to go and look it up. Why
> use the phrase at all, when it doesn't add any value?
>
>> Until J Random Newbie is able to hold that entire complex
>> thought in his head, he's not going to be able to be an effective C
>> programmer.
>
> We can ease that journey by not giving him useless junk to remember.
>
>> Pass by reference is a very common and useful programming technique,
>> one that C supports quite well (though arguably a little more clumsily
>> than some other languages do).
>
> I know what you're saying, but I think that's an own-foot-shooting way to
> say it.

Ok, I see your point. I suppose it depends on the kind of newbie.

Personally, I learned Pascal before I learned C, so I already knew
about pass-by-value and pass-by-reference. From that perspective,
understanding that passing a pointer is the way to emulate
pass-by-reference in C was very important. Things might be different
for a non-programmer learning C.

On the other hand, I'm not sure that C is a good choice for a first
language. In any case, a programmer should *eventually* understand
the concepts of pass-by-value and pass-by-reference. And I tend to
think that it's at least as important to use C (or any language) as a
vehicle for learning about programming as it is to learn the details
of the language itself.

--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.



Relevant Pages

  • Re: Boxing and Unboxing ??
    ... The advance from machine language to assembly language abstracted ... reference type} detail with no loss to performance. ... C++ has a unified type system that essentially lets the programmer do ... that they care about which operand is located in which machine register, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boxing and Unboxing ??
    ... abstraction where programmers writing programs in this language never have any ... reason to know the first thing about separate value types and reference types, ... C++ has a unified type system that essentially lets the programmer do ... the programmer using the language will care about these to the same degree ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boxing and Unboxing ??
    ... feature is worth the additional complexity it adds to the language. ... arbitrary type that could be a value type or a reference type, ... Person that has space allocated for it on the heap. ... the programmer will not even need to know the difference. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Question on LSP
    ... not have to be explicit attributes, ... Since objects in memory usually don't move, the language can largely hide the identity mapping. ... My issue here is that whatever semantic meta model the language uses, there must be some way for the developer to unambiguously express the OOA/D is-a semantics for some problem space entity. ... Note that the language allows us to use a name like 'T' on the reference as a mnemonic so that the developer can keep track of what is happening with the indirection. ...
    (comp.object)
  • Re: Modifying Class Object
    ... last attempt to do so since you chose to be inflammatory in your ... The syntax of python is simply and shortly defined in a machine ... In theory when talking about a language, we do not need to talk ... Not a reference. ...
    (comp.lang.python)