Jump to content

Talk:Declaration (computer programming): Difference between revisions

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
Content deleted Content added
Cewbot (talk | contribs)
m Maintain {{WPBS}} and vital articles: 2 WikiProject templates. Create {{WPBS}}. Keep majority rating "Start" in {{WPBS}}. Remove 2 same ratings as {{WPBS}} in {{WikiProject Computing}}, {{WikiProject Computer science}}.
 
(13 intermediate revisions by 9 users not shown)
Line 1: Line 1:
{{WikiProject Computing|class=Start|importance=Low}}
{{WikiProject banner shell|class=Start|
{{WikiProject Computer science|class=Start|importance=Low}}
{{WikiProject Computing|importance=mid}}
{{WikiProject Computer science|importance=mid}}
}}


The code examples are interchanged, aren't they?
== Code examples ==


—– [[User:195.14.207.180|195.14.207.180]] 11:05, 18 August 2006 (UTC)
The code examples are interchanged, aren't they? -- [[User:195.14.207.180|195.14.207.180]] 11:05, 18 August 2006 (UTC)


Yes. I'll change them. Hopefully my change won't be regarded as vandalism (like the last attemt to change it was, back on 11 May). --[[User:Rhebus|Rhebus]] 11:52, 18 August 2006 (UTC)
Yes. I'll change them. Hopefully my change won't be regarded as vandalism (like the last attempt to change it was, back on 11 May). -- [[User:Rhebus|Rhebus]] 11:52, 18 August 2006 (UTC)


== initialization ==
== Initialization ==


Initialization = definition? --[[User:Abdull|Abdull]] ([[User talk:Abdull|talk]]) 19:53, 21 December 2007 (UTC)
Initialization = definition? --[[User:Abdull|Abdull]] ([[User talk:Abdull|talk]]) 19:53, 21 December 2007 (UTC)
Line 22: Line 24:
</blockquote>
</blockquote>
Definitions in C (such as int x = 7; at the top of a function) are also declarations, but a (pure) declaration is not a definition and reserves no memory. "extern char example1;" won't reserve any memory. [[Special:Contributions/81.131.65.15|81.131.65.15]] ([[User talk:81.131.65.15|talk]]) 12:13, 5 April 2010 (UTC)
Definitions in C (such as int x = 7; at the top of a function) are also declarations, but a (pure) declaration is not a definition and reserves no memory. "extern char example1;" won't reserve any memory. [[Special:Contributions/81.131.65.15|81.131.65.15]] ([[User talk:81.131.65.15|talk]]) 12:13, 5 April 2010 (UTC)

== Contradiction pertaining to definition of "Definition" ==

The definition of "definition" given is "definitions (declarations which provide the actual implementation in the case of functions, and initialization in the case of variables)", which is contradicted by the line below:
Here are some examples of definitions, again in C:
char example1; <span style="font-size: smaller;" class="autosigned">—Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/69.191.241.48|69.191.241.48]] ([[User talk:69.191.241.48|talk]]) 13:49, 16 March 2011 (UTC)</span><!-- Template:UnsignedIP --> <!--Autosigned by SineBot-->

I concur with the opinion above: the definition of "definition" is incorrect. See eg. "C++ FAQ Lite", Section [10.13] "Can I add = initializer; to the declaration of a class-scope static const data member?" [[Special:Contributions/71.146.78.75|71.146.78.75]] ([[User talk:71.146.78.75|talk]]) 15:20, 25 August 2011 (UTC)

== Merge suggestion ==
See [[Talk:Initialization_(programming)#Merge suggestion]]. [[User:A.A.Graff|A.A.Graff]] ([[User talk:A.A.Graff|talk]]) 04:03, 21 May 2010 (UTC)

== Distinguish between the definition of a function and a declaration of a variable. ==

Make at least 2 sections. Better would be to have 2 articles.--[[Special:Contributions/92.193.45.68|92.193.45.68]] ([[User talk:92.193.45.68|talk]]) 20:30, 22 October 2012 (UTC)

Latest revision as of 15:45, 31 January 2024

Code examples

[edit]

The code examples are interchanged, aren't they? -- 195.14.207.180 11:05, 18 August 2006 (UTC)[reply]

Yes. I'll change them. Hopefully my change won't be regarded as vandalism (like the last attempt to change it was, back on 11 May). -- Rhebus 11:52, 18 August 2006 (UTC)[reply]

Initialization

[edit]

Initialization = definition? --Abdull (talk) 19:53, 21 December 2007 (UTC)[reply]

No. For variables, reserving memory = definition, initialization = initialization. The article is misleading. 81.131.65.15 (talk) 12:18, 5 April 2010 (UTC)[reply]

Declarations don't necessarily reserve memory, and if they do, they are definitions

[edit]

"For variables, definitions assign values to an area of memory that was reserved during the declaration phase." That's not correct. From The C Programming Language, Appendix 8:

Declarations specify the interpretation given to each identifier; they do not necessarily reserve storage associated with the identifier. Declarations that reserve storage are called definitions.

Definitions in C (such as int x = 7; at the top of a function) are also declarations, but a (pure) declaration is not a definition and reserves no memory. "extern char example1;" won't reserve any memory. 81.131.65.15 (talk) 12:13, 5 April 2010 (UTC)[reply]

Contradiction pertaining to definition of "Definition"

[edit]

The definition of "definition" given is "definitions (declarations which provide the actual implementation in the case of functions, and initialization in the case of variables)", which is contradicted by the line below: Here are some examples of definitions, again in C: char example1; —Preceding unsigned comment added by 69.191.241.48 (talk) 13:49, 16 March 2011 (UTC)[reply]

I concur with the opinion above: the definition of "definition" is incorrect. See eg. "C++ FAQ Lite", Section [10.13] "Can I add = initializer; to the declaration of a class-scope static const data member?" 71.146.78.75 (talk) 15:20, 25 August 2011 (UTC)[reply]

Merge suggestion

[edit]

See Talk:Initialization_(programming)#Merge suggestion. A.A.Graff (talk) 04:03, 21 May 2010 (UTC)[reply]

Distinguish between the definition of a function and a declaration of a variable.

[edit]

Make at least 2 sections. Better would be to have 2 articles.--92.193.45.68 (talk) 20:30, 22 October 2012 (UTC)[reply]