Smalltalk Keyword names for Javascript method calls

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Smalltalk Keyword names for Javascript method calls

Sophie424
Currently in a message send, keywords after the first are ignored. So:

anObject css: 'background' backColor: 'red'  
   and
anObject css: 'background' frontColor: 'red'  

both map to
anObject.
css('background', 'red')

That can make the ST source confusing. Is there any way possible that Amber can improve this, or is it impossible given the combination of

(a) css:backColor: and css:frontColor: are both valid Smalltalk messages,
(b) everything is dynamic e.g. no way to know the Javascript parameter name used for 'red'.

Thanks!
Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk Keyword names for Javascript method calls

Sophie424
Btw, I think this cannot be done, but just asking since others here
are waaay smarter than I am anyway :-)

Reply | Threaded
Open this post in threaded view
|

Re: Smalltalk Keyword names for Javascript method calls

Nicolas Petton
In reply to this post by Sophie424
At first it was:
anObject css: #('background' 'red')

But you quickly end up using arrays as parameters everywhere.
So I think the current solution is way better.

And BTW, GNU Smalltalk does the same for the Java binding.

Cheers,
Nico
On Sat, 2012-01-28 at 09:28 -0800, Sophie wrote:

> Currently in a message send, keywords after the first are ignored. So:
>
> anObject css: 'background' backColor: 'red'  
>    and
> anObject css: 'background' frontColor: 'red'  
>
> both map to
> anObject.css('background', 'red')
>
> That can make the ST source confusing. Is there any way possible that
> Amber can improve this, or is it impossible given the combination of
>
> (a) css:backColor: and css:frontColor: are both valid Smalltalk
> messages,
> (b) everything is dynamic e.g. no way to know the Javascript parameter
> name used for 'red'.
>
> Thanks!