Content deleted Content added
AmirOnWiki (talk | contribs) |
remove |
||
(27 intermediate revisions by 17 users not shown) | |||
Line 1:
{{Talk header}}
{{WikiProject Computing|class=|importance=}}▼
{{WikiProject banner shell|class=C|
}}
==Is eval reflection?==
I don't think eval should be considered in creating examples of reflection in programming languages. Few programs would ever use eval, and none would use it to hack around language limitations.
==Python Example==
Line 13 ⟶ 19:
</blockquote>
This just means that reflection is the ''ability of a program to reason about itself''. So the first sentence of the article is on toppic, the rest is about Reflection-oriented programming
[[Special:Contributions/134.58.39.247|134.58.39.247]] ([[User talk:134.58.39.247|talk]]) 08:31, 20 October 2008 (UTC)
::I agree with you, but reasoning is too ambiguous and more in the field of [[Artificial Intelligence|AI]]. It seems that more peopole thing about this term in the context of programming languages, although theoretically this concept is as old as the [[Universal Turing Machine]] which lead to the concept or programmable computers. A program that reason about it self is more interesting from a philosophic perspective. <!-- Template:Unsigned IP --><small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/2806:107E:4:4B49:218:DEFF:FE2B:1215|2806:107E:4:4B49:218:DEFF:FE2B:1215]] ([[User talk:2806:107E:4:4B49:218:DEFF:FE2B:1215#top|talk]]) 20:08, 2 May 2017 (UTC)</small> <!--Autosigned by SineBot-->
==MOO code==
Line 120 ⟶ 128:
<div class="boilerplate" style="background-color: #eeffee; margin: 2em 0 0 0; padding: 0 10px 0 10px; border: 1px dotted #AAAAAA;"><!-- Template:polltop -->
:''The following discussion is an archived debate of the {{{type|proposal}}}. <
{{{result|The result of the debate was}}} '''move'''. —[[User:Nightstallion|<span style="font-variant:small-caps">Nightst</span>]]
==Requested move==
* [[Computational reflection]] → '''[[Reflection (computer science)]]'''
----
:''Add *'''Support''' or *'''Oppose''' followed by an optional one-sentence explanation, then sign your opinion with ''<nowiki>~~~~</nowiki>
*'''Support''' --[[User:Soumyasch|Soumyasch]] 05:03, 27 March 2006 (UTC)
:''The above discussion is preserved as an archive of the debate. <
== Example applications? ==
Line 173 ⟶ 181:
All the code examples of reflection just regard what's [[dynamic dispatch]], but reflection is ''much more''. Better example needed. <span style="color: #800000; background-color: #FFFF80; padding: 1px 2px 3px 2px">''Said: [[User talk:Rursus|Rursus]] [[User:Rursus/OTHITPWMEEENAE|☺]] [[User:Rursus|★]]''</span> 17:10, 2 June 2007 (UTC)
[[WP:SOFIXIT]] :D --<span style="background-color: #Fda;">''[[User:Soumyasch|<
== C# Example doesn't fit ==
Line 218 ⟶ 226:
Truly reflective language, worth mention! The original example:
<
foo: make object! [
hello: does [print "Hello"]
Line 228 ⟶ 236:
; with reflection
do get in foo to-word "hello"
</syntaxhighlight>
Fully featured example:
<
foo: func [/local name code start-mark end-mark] [
name: ask "What is your name?^/"
Line 247 ⟶ 255:
)
]
</syntaxhighlight>
Running the code:
<pre>
Line 313 ⟶ 321:
:Based on the current contents of these categories, [[:Category:Programming constructs]] seems most appropriate. There is a certain ambiguity in its relation to [[:Category:Programming language concepts]] - there is room for some cleanup and reorganization there. [[User:AmirOnWiki|AmirOnWiki]] ([[User talk:AmirOnWiki|talk]]) 11:44, 10 October 2013 (UTC)
== Tabbed UI for examples ==
Would be nice if all examples could be in one place shown as tabs, like MSDN articles do.
When printing the currently selected/visible one could be printed instead of everything <small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/213.16.221.149|213.16.221.149]] ([[User talk:213.16.221.149|talk]]) 14:54, 4 March 2015 (UTC)</small><!-- Template:Unsigned IP --> <!--Autosigned by SineBot-->
== PHP example - variable variable syntax ==
The PHP example currently contains this section:
<pre>
// With reflection, using variable variables syntax
$className = 'Foo';
$foo = new $className();
$method = 'hello';
$foo->$method();
</pre>
Now, as far as I can see, this method isn't really an example of reflection but it is rather a language feature that allows you to reference a symbol indirectly via a variable. As such it is very similar to taking the approach in Javascript (for example) of using indexing on the global object rather than direct references, e.g. translating <code>new Foo()</code> to <code>new window['Foo']()</code>. Specific reasons I don't believe this qualifies as reflection:
* It doesn't allow introspection, only indirection.
* You can't get a list of available classes using this technique.
* Given a class name, you can't tell if it exists or not (other than by attempting to create one and catching the exception if that fails).
* Given a class name, you can't get a list of its methods (other than by instantiating it, and examining the resulting object to find out its properties, which you would need to do using an *actual* reflection API, rather than this technique).
I'm therefore not convinced that this example belongs here. It's an interesting hack, and a useful, simple way of creating dynamic behaviour, but due to lacking facilities for introspection, I'm not convinced it's an example of ''Reflection''. Opinions? [[User:JulesH|JulesH]] ([[User talk:JulesH|talk]]) 00:39, 22 January 2018 (UTC)
==Reflection in BASIC==
Would functions in BASIC be considered a form of reflection with def fn? Since functions themselves are defined in BASIC and can (depending on the implementation be redefined). [[User:ZhuLien|ZhuLien]] ([[User talk:ZhuLien|talk]]) 11:52, 6 March 2018 (UTC) <!-- Template:Unsigned IP --><small class="autosigned">— Preceding [[Wikipedia:Signatures|unsigned]] comment added by [[Special:Contributions/118.127.112.218|118.127.112.218]] ([[User talk:118.127.112.218#top|talk]]) </small> <!--Autosigned by SineBot-->
==Compile time reflection==
The article begins with:
"In computer science, reflection is the ability of a computer program to examine, introspect, and modify its own structure and behavior at runtime."
However, e.g. Heron and C++ communities know the concept of compile-time reflection. I think the scope of the article should also include these since they're used in similar ways as runtime reflection.
Sources:
* http://www.drdobbs.com/windows/compile-time-reflection-metaprogramming/228700607
* https://www.gnu.org/software/gcc/projects/cxx-reflection/
* http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2016/p0385r0.pdf
* https://rly.sexy/post/basic-reflection-in-pure-cpp17
The P0385R0 document has the following definition for reflection:
"In the context of computer science, the term reflection refers to the ability of a program to examine and possibly modify its own structure and/or behavior.
When combined with metaprogramming, this can include modification of the existing or the definition of new data structures, doing changes to algorithms or changing the way a program code is interpreted"
[[Special:Contributions/2001:14BA:1AFC:72F0:0:0:0:E18|2001:14BA:1AFC:72F0:0:0:0:E18]] ([[User talk:2001:14BA:1AFC:72F0:0:0:0:E18|talk]]) 03:39, 5 March 2019 (UTC)
::I agree with this. The [https://davidchristiansen.dk/david-christiansen-phd.pdf PhD dissertation by David Christiansen] on the reflection system of [[Idris (programming language)|Idris]] also defines reflection similarly, does not limit it to runtime. [[User:TuXie|TuXie]] ([[User talk:TuXie|talk]]) 18:21, 25 April 2019 (UTC)
|