Smalltalk Keyword names for Javascript method calls

classic Classic list List threaded Threaded
3 messages Options
Sophie424 Sophie424
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Smalltalk Keyword names for Javascript method calls

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!
Sophie424 Sophie424
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Smalltalk Keyword names for Javascript method calls

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

Nicolas Petton Nicolas Petton
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: Smalltalk Keyword names for Javascript method calls

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!


Loading...