Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Charlie Robbats
Oops, that should be.. | array lookupClosure performClosure | lookupClosure := []. lookupClosure := [:cls :selector | (cls == nil) ifTrue: [Warning signal: ('method lookup failure: ', selector)]. cls methodDictionary at: selector ifP

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Charlie Robbats
and a little block cleanup: | array lookupClosure performClosure | lookupClosure := []. lookupClosure := [:cls :selector | (cls == nil) ifTrue: [Warning signal: ('method lookup failure: ', selector)]. cls methodDictionary at: selector

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Charlie Robbats
Here's a little change to get your #perform:withArguments: implemented. | array lookupClosure method | array := { 1 }. lookupClosure := []. lookupClosure := [:cls :selector | (cls == nil) ifTrue: [Warning signal: ('method lookup failure: ', selector)]. cls methodDictionary

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Charlie Robbats
Thanks, that's a good improvement, more readable. On 10/16/2016 9:32 AM, Ben Coman wrote: On Sun, Oct 16, 2016 at 9:11 PM, Charlie Robbats wrote: Here, Dmitry, try this code in playground...maybe helps you understand | lookupClosure | lookupClosure := []. lookupClosure := [:cls :selector |

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Ben Coman
On Sun, Oct 16, 2016 at 9:11 PM, Charlie Robbats wrote: > Here, Dmitry, try this code in playground...maybe helps you understand > > | lookupClosure | > lookupClosure := []. > lookupClosure := [:cls :selector | > (cls == nil) > ifTrue: [Warning signal: ('selector lookup failure: ', sel

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread CodeDmitry
Thanks! That works! (And I learned that I can create collections with {a. b. c} syntax). -- View this message in context: http://forum.world.st/How-do-Smalltalk-disambiguate-messages-tp4918946p4918973.html Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Charlie Robbats
Here, Dmitry, try this code in playground...maybe helps you understand | lookupClosure | lookupClosure := []. lookupClosure := [:cls :selector | (cls == nil) ifTrue: [Warning signal: ('selector lookup failure: ', selector)]. (cls methodDictionary at: selector ifAbs

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Ben Coman
On Sun, Oct 16, 2016 at 8:38 PM, Nicolai Hess wrote: > Am 16.10.2016 14:35 schrieb "CodeDmitry" : >> >> I define Magic as "An opaque abstraction or an abstraction you think is >> opaque until you learn better.", to a beginner, everything is deeply >> Magical. >> >> That said, much of Smalltalk's o

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Ben Coman
On Sun, Oct 16, 2016 at 12:44 PM, CodeDmitry wrote: > I understand that it is a single message send, but to know how to handle the > message at runtime, the parser needs to somehow determine where the > implementation of that message is. It must do a lookup based on multiple > keys(at, and put),

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Dimitris Chloupis
Smalltalk does not allow you to do calls of any kind, everything goes through the messaging system . To have the same in another language you will have to disable the ability to call functions and method and replace them with messages. No language such feature not even lisp, the language that excel

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Mark Bestley
For an example of a working bridge between the two ways of methods and function see PyObjc which allows Python code to call Objective C messaging (e.g in a similar form to your mapping Javascript to Smalltalk - except Javascript is not class based) https://pythonhosted.org/pyobjc/core/intro.h

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Nicolai Hess
Am 16.10.2016 14:35 schrieb "CodeDmitry" : > > I define Magic as "An opaque abstraction or an abstraction you think is > opaque until you learn better.", to a beginner, everything is deeply > Magical. > > That said, much of Smalltalk's opaqueness is not due to the language, but > due to me being a

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread CodeDmitry
I define Magic as "An opaque abstraction or an abstraction you think is opaque until you learn better.", to a beginner, everything is deeply Magical. That said, much of Smalltalk's opaqueness is not due to the language, but due to me being a beginner. I'm sure there's a way to actually force sendi

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Tudor Girba
Hi, > On Oct 16, 2016, at 10:41 AM, CodeDmitry wrote: > > I was actually curious about this in Ruby as well, since Ruby also doesn't > have the Smalltalk message syntax. > > I figure that the magic behind it is that Smalltalk takes strings like "dict > at: 'foo' put: 'bar'" and evaluates them

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread CodeDmitry
"Messages are very hard to implement if not impossible because they required that calls don't exist or be disabled, otherwise the existence of message is pointless. And since no language I am aware of allow you to disable calls and replace them with messages , what you trying to do is pointless ."

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Dimitris Chloupis
Still you don't understand how Ruby syntax works. Every method call every function you see is basically a masquerade message sent. Those calls are just syntactic sugar, they don't exist, they are there to make people to feel more comfortable giving them the illusion that is a call because it looks

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread CodeDmitry
I tried so hard to find an example of Ruby using smalltalk message syntax. You can do something like: class Dictionary attr_accessor :dict def initialize() @dict = {} end def at(*args) if (args.length == 1) then return @dict[args[0]]

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Dimitris Chloupis
"I was actually curious about this in Ruby as well, since Ruby also doesn't have the Smalltalk message syntax. " Actually, it does when i said in my reply "The only other languages that have such an implementation are ObjC and Ruby which borrow this directly from Smalltalk." What I mean is that

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread CodeDmitry
I was actually curious about this in Ruby as well, since Ruby also doesn't have the Smalltalk message syntax. I figure that the magic behind it is that Smalltalk takes strings like "dict at: 'foo' put: 'bar'" and evaluates them into a JavaScript equivalent of "dict['at:put:']('foo', 'bar')". Basi

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-16 Thread Dimitris Chloupis
`There is no equivalent in JavaScript because Javascript does not have function calls with keyword arguments and even if it , it would still be not equivalent at least technically. The message "at:put:" is indeed a keyword that is part of the dictionary of the object and not just a generic diction

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-15 Thread Tudor Girba
The value of the method name is at:put: # denotes a Symbol, which is a subclass of String. The difference between the two is that two symbols with the same value will actually be the same object, while this is not necessarily the case with strings: stringA := String newFrom: 'string'. stringB :

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-15 Thread CodeDmitry
So "at: x put: y" translates to a method named #at:put:(or "at:put:")? |dict| dict := Dictionary new. dict at: 'foo' put: 'bar'. So javascript equivalent would be(assuming the Dictionary object existed). var dict; dict = new Dictionary; dict['at:put:']('foo', 'bar'); -- View this message in

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-15 Thread Charlie Robbats
I think the nub of your confusion is twofold. The method #at:put: is a keyword method and it isn't right to think o them as two keys. It is one compound key and unlike most every other system, Smalltalk keyword message sends allow the programmer to name each argument. This is very fine indeed.

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-15 Thread CodeDmitry
I understand that it is a single message send, but to know how to handle the message at runtime, the parser needs to somehow determine where the implementation of that message is. It must do a lookup based on multiple keys(at, and put), which is really confusing. "methods" are easy to look up becau

Re: [Pharo-users] How do Smalltalk disambiguate messages?

2016-10-15 Thread Gabriel Cotelli
The message is "at:put:". It's a single message send. I encourage you to try the ProfStef tutorial to understand the basis. On Oct 16, 2016 01:17, "CodeDmitry" wrote: > I am trying to do a JavaScript experiment to make Objects behave like > Smalltalk objects. > > example: > > "reminder: Sm

[Pharo-users] How do Smalltalk disambiguate messages?

2016-10-15 Thread CodeDmitry
I am trying to do a JavaScript experiment to make Objects behave like Smalltalk objects. example: "reminder: Smalltalk arrays start at 1." |arr| a := Array new: 1. a at: 1 put: 'Hello, World'. Here, the Smalltalk array has a message "at: index put: value" which is defined ma