功能是地址 [英] A function is an address

查看:46
本文介绍了功能是地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在语义方面忽略实现细节并严格遵循C99

标准,是否有任何根本缺陷

描述使用(非内联)函数作为地址[1]?我感觉好像我错过了一些明显的东西。

-Jul


[1]为了保持上下文,这是为了向初学者描述

函数。

解决方案

Julienne Walker写道:
< blockquote class =post_quotes>
忽略实现细节并严格遵循C99

标准的语义,是否有任何根本缺陷

描述使用一个(非内联)函数作为地址[1]?我感觉好像我错过了一些明显的东西。



将函数描述为
a custard pie可能更好。


-Jul


[1]为了保持上下文,这是为了向初学者描述

函数。



哦,初学者?在那种情况下,乳蛋糕馅饼是指乳蛋糕馅饼。到目前为止

是介绍该主题的最佳方式。后来,当学生

获得了一些理解和经验时,你可以回到

并解释奶油馅饼。真的是一个简化;

完全通用一个功能可以是任何一种甜点或

喜剧道具。


(换句话说,你是否已经离开了你的感官,

或者他们已经离开了你?或者你是一个门徒?
Humpty Dumpty,决心说出意思无论你想要什么?b $ b想要他们而不考虑其他人的想法

他们的意思是什么?)


-
Er*********@sun.com


Julienne Walker写道:


忽略实现细节并严格遵循C99

标准的语义,有什么从根本上有缺陷

描述使用(非内联)函数作为地址[1]?我感觉好像我错过了一些明显的东西。



函数通常有一个相关的内存地址,表示该函数的

入口点。一个函数不是一个地址,比你的房子是一个地址更多



Julienne Walker< ha ****** ***@hotmail.comwrites:


忽略实现细节并严格遵循C99

标准的语义,有什么根本的东西有缺陷的

描述了使用(非内联)函数作为地址[1]?我感觉好像我错过了一些明显的东西。


[1]为了保持上下文,这是参考描述

对初学者起作用。



我不能想到任何事情*没有*根据描述

使用函数作为地址的根本缺陷。 />

我怀疑你在想的是

函数类型的表达式(包括函数的名称)是,除非它''是一元的sizeof的

操作数或&运算符,隐式转换为

函数的地址,以及函数调用的第一个操作数

运算符实际上是指向函数的指针,不一定是

功能。我确定常见问题解决了这个问题。


但这并不意味着函数*是*一个地址(它不是),

并不一定是初学者会提到的东西。


直到初学者开始明确地使用函数指针,它才是

可能会说函数调用func(arg1,arg2)调用

指定的函数并将其传递给指定的参数。

的事实是,转换为函数指针发生在

后面的场景可能要等到以后。


-

Keith Thompson(The_Other_Keith)< ks *** @ mib.org>

在圣地亚哥地区寻找软件开发工作。

我们必须做点什么。这是事情。因此,我们必须这样做。

- Antony Jay和Jonathan Lynn,是部长


Ignoring implementation details and strictly following the C99
standard in terms of semantics, is there anything fundamentally flawed
with describing the use of a (non-inline) function as an address[1]? I
keep feeling like I''m missing something obvious.
-Jul

[1] To keep things in context, this is in reference to describing
functions to a beginner.

解决方案

Julienne Walker wrote:

Ignoring implementation details and strictly following the C99
standard in terms of semantics, is there anything fundamentally flawed
with describing the use of a (non-inline) function as an address[1]? I
keep feeling like I''m missing something obvious.

It would probably be better to describe a function as
a custard pie.

-Jul

[1] To keep things in context, this is in reference to describing
functions to a beginner.

Oh, a beginner? In that case, "custard pie" is by far
the best way to introduce the topic. Later, when the pupil
has gained some understanding and experience, you can go
back and explain that "custard pie" is really a simplification;
in full generality a function can be any kind of dessert or
comedic prop whatsoever.

(In other words, have you taken leave of your senses,
or have they taken leave of you? Or are you a disciple of
Humpty Dumpty, determined to make words mean whatever you
want them to and without regard to what others may think
they mean?)

--
Er*********@sun.com


Julienne Walker wrote:

Ignoring implementation details and strictly following the C99
standard in terms of semantics, is there anything fundamentally flawed
with describing the use of a (non-inline) function as an address[1]? I
keep feeling like I''m missing something obvious.

A function typically has an associated memory address indicating the
entry point for the function. A function is not an address, any more
than your house is an address.


Julienne Walker <ha*********@hotmail.comwrites:

Ignoring implementation details and strictly following the C99
standard in terms of semantics, is there anything fundamentally flawed
with describing the use of a (non-inline) function as an address[1]? I
keep feeling like I''m missing something obvious.

[1] To keep things in context, this is in reference to describing
functions to a beginner.

I can''t think of anything *not* fundamentally flawed about describing
the use of a function as an address.

I suspect what you''re thinking of is the fact that an expression of
function type (including the name of a function) is, unless it''s the
operand of a unary "sizeof" or "&" operator, implicitly converted to
the function''s address, and the first operand of a function call
operator is actually a pointer-to-function, not necessarily a
function. I''m sure this is covered in the FAQ.

But this does not imply that a function *is* an address (it isn''t),
and it''s not necessarily something I''d mention to beginners.

Until a beginner starts to use function pointers explicitly, it
probably sufices to say that a function call func(arg1, arg2) calls
the specified function and passes it the specified arguments. The
fact that there''s a conversion to a function pointer happening behind
the scenes can probably wait until later.

--
Keith Thompson (The_Other_Keith) <ks***@mib.org>
Looking for software development work in the San Diego area.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"


这篇关于功能是地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆