Talk:Create an object/Native demonstration: Difference between revisions

 
(13 intermediate revisions by 9 users not shown)
Line 6:
 
:I am not sure that that was the right choice here. The task is titled "Create an Object/Native ...", and while TCL might not have objects it certainly has native stuff? Anyways, this site has always been about closest approximations (though I have been known to quibble about where we draw the boundaries on those issues). --[[User:Rdm|Rdm]] 12:46, 20 October 2010 (UTC)
 
:: The [[Perl]] solution will need to use [http://perldoc.perl.org/perltie.html perltie] to tie a <tt>%hash</tt> to some <tt>$object</tt>, so that <tt>%hash{$key} = $value</tt> calls the magic method <tt>$object->STORE($key, $value)</tt>, and one writes code for <tt>STORE</tt>. If Perl has no perltie feature, I would omit this task from Perl. If Tcl has both dicts and objects, but Tcl has nothing like perltie, then one should omit this task from Tcl. --[[User:Kernigh|Kernigh]] 02:51, 17 February 2011 (UTC)
 
::: Hmm, I suppose I could use a trace on an array to stop someone from changing it (which would be similar in spirit to the perltie approach). Ugly as anything though. It's also not really what I'd call writing a ''native'' implementation of the “object”; it's layering a whole load off stuff over the top instead. Dictionary values work just as fine for non-modifiable (as Tcl's value-model is based on immutable values) but there I think it's violating the spirit of the task. –[[User:Dkf|Donal Fellows]] 12:19, 10 March 2013 (UTC)
 
:::: Just for the fun of it, I have added a Tcl implementation with variable traces. - [[User:Suchenwi|Suchenwi]] ([[User talk:Suchenwi|talk]]) 13:26, 7 May 2015 (UTC)
 
== wrong name? ==
 
I think this task might have the wrong name. It might be better to call it "immutable map" or something like that. It's not so much a demonstration of creating an object and "native demonstration" doesn't make sense to me. --[[User:Mwn3d|Mwn3d]] 22:31, 16 February 2011 (UTC)
:Sorry to causing misunderstanding. I think Ruby's demonstration match, and in fact correct, my idea. The object requirements should be 1. No new KEY could be added, and KEY set at initialization cannot be removed ; 2. VALUE can be modified and can be reset (by method delete/reset/clear etc. whatever appropriate in the language) to DEFAULT VALUE which has been set at initialization. But the object creation task is just a means to expose those Magic Method, which is the real goal of this task. For example, one can make a hash class object that access values by key by using a method '''getValueByKey''', or by using a Native(?) method, for example in D, '''opIndex'''. It is this '''opIndex''' that I called Magic Method. I cannot express my idea well :( [[User:Dingowolf|dingowolf]] 23:19, 16 February 2011 (UTC)
 
:I too can see that it is '''not''' the fact that you are indeed creating an immutable map that is the point. It is how to make an object that acts just as a map does/should do, but with your outlined changes. I cannot come up with a better name than you have, at the moment.Oh wait, how about ''"Emulating a native type"'' ? --[[User:Paddy3118|Paddy3118]] 02:34, 17 February 2011 (UTC)
 
:I am the author of the Ruby code in progress. I chose the name "fenced hash" in the Ruby code, but "fenced hash" might be bad name of page. I had trouble with two parts of the task description. First, I had to guess what "No new item can be added" does mean. For the Ruby code, I decided that no new KEY can be added. Second, I know what is "native hash", but I am not understanding what is "native way of object creation" or "native demonstration". The word "native" would have different meaning there. After I finish the Ruby code, I might edit the task description. After we fix the task description, we should drop "native demonstration" name. --[[User:Kernigh|Kernigh]] 02:51, 17 February 2011 (UTC)
:: And what do you think about the name ''"Emulating a native type"'' ? --[[User:Paddy3118|Paddy3118]] 05:12, 17 February 2011 (UTC)
::: More specifically, how about something in the direction of [[Associative Array/Emulation]]? That should relate well to [[Associative arrays/Creation]], and include a more specific hint as to what kind of native type is being emulated. --[[User:Short Circuit|Michael Mol]] 13:45, 17 February 2011 (UTC)
:::: I am not sure whether "Emulating an associative array" or "Emulating a native type" is better. I hate the names of the [[Associative arrays/Creation]] and [[Associative arrays/Iteration]] pages, because the slash suggests that these are subpages of an "Associative arrays" page, but there is no such page. (The [[Associative array]] page has no final "s".) --[[User:Kernigh|Kernigh]] 23:08, 21 February 2011 (UTC)
::::: Should we rename those by dropping the s?[[User:Markhobley|Markhobley]] 22:58, 6 July 2011 (UTC)
I agree this task needs a new name. What about Fixed Associative Map?
[[User:Garbanzo|Garbanzo]] ([[User talk:Garbanzo|talk]]) 20:31, 30 January 2021 (UTC)
==Changed wording==
I reworded the task based on the discussion above and the Ruby and D implementations. I tried to keep the meaning the same but it looks like not everyone had the same interpretation. I removed "magic methods" because none of the implementations mentioned it. Feel free to change it back or clean it up if I got something wrong.
[[User:Garbanzo|Garbanzo]] ([[User talk:Garbanzo|talk]]) 04:51, 31 January 2021 (UTC)
 
:I thought your changes might have been too much so added something back, as well as my own slant. What do you think?
:--[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 06:41, 31 January 2021 (UTC)
::Mentioning that the values can be modified is a good catch. For delete vs. reset, the original mentioned delete so that is less of a change but the semantics of using delete to restore values won't be idiomatic in many languages - maybe this could be left up to the implementers? For "magic methods", I wasn't sure what it was expecting. Is it operator overloading in this case? [[User:Garbanzo|Garbanzo]] ([[User talk:Garbanzo|talk]]) 08:08, 31 January 2021 (UTC)
125

edits