Re: Difference between variables and functions
From: Ulrich Hobelmann (u.hobelmann_at_web.de)
Date: 08/30/05
- Previous message: Ulrich Hobelmann: "Re: Writing portable applications"
- In reply to: joe_at_invalid.address: "Re: Difference between variables and functions"
- Next in thread: Wayne C. Morris: "Re: Difference between variables and functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 30 Aug 2005 13:07:53 +0200
joe@invalid.address wrote:
> The OP's code set an int to 4. Then it tried to call the value 4 as a
> function, which would mean (I guess) that the compiler was expected to
> generate code that would just jump to address 4 and start executing.
>
> There have been several good responses based on the definition of
> C. I'm just wondering why you think it would be a good thing for the
> compiler to blissfully cast the number 4 to a pointer to function and
> try to start executing code at that address?
No, as Keith writes, I was under the impression that C had somewhat
loose type-checking, when often it doesn't. Thanks to you guys for
educating me!
> I'm not an expert though, I'm just asking. The fact that it won't do
> that seems more like reasonable than anal to me.
Sure, the call doesn't make sense. It was my wrong understanding of C's
type system that led me to expect that a call to "4" should be compiled ;)
-- My ideal for the future is to develop a filesystem remote interface (a la Plan 9) and then have it implemented across the Internet as the standard rather than HTML. That would be ultimate cool. Ken Thompson
- Previous message: Ulrich Hobelmann: "Re: Writing portable applications"
- In reply to: joe_at_invalid.address: "Re: Difference between variables and functions"
- Next in thread: Wayne C. Morris: "Re: Difference between variables and functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|