some strange when I call JS function from Amber

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

some strange when I call JS function from Amber

SeungBum Kim
Hi,

I played with Amber today, and it was great fun. http://yfrog.com/nwytxp

But I feel strange when I call JS function from Amber, such as canvas 'clearRect' function.

Although argument for clearRect() is "float x, float y, float w, float h", I should call it with "clearRect:y:to:y:". "to:y:" for width and height.

And using an array for the method doesn't work in Amber like 'canvas clearRect: #(0 0 10 10)'. I think I saw this kind of notation from somewhere. right? 




--
김 승 범 (SB Kim)
New Media Literacy Education
010 - 2686 - 6855
http://xenbio.net | http://smalltalk.kr

Reply | Threaded
Open this post in threaded view
|

Re: some strange when I call JS function from Amber

Nicolas Petton

On Wed, 2011-10-26 at 01:08 +0900, SeungBum Kim wrote:

> Hi,
>
>
> I played with Amber today, and it was great
> fun. http://yfrog.com/nwytxp
>
> But I feel strange when I call JS function from Amber, such as canvas
> 'clearRect' function.
>
>
> Although argument for clearRect() is "float x, float y, float w, float
> h", I should call it with "clearRect:y:to:y:". "to:y:" for width and
> height.
>
>
> And using an array for the method doesn't work in Amber like 'canvas
> clearRect: #(0 0 10 10)'. I think I saw this kind of notation from
> somewhere. right?

yes, but this is old and has been changed. Sometimes it may feel strange
whith functions that take a lot of arguments, but most of the time it's
way better than using arrays as arguments.

Cheers,
Nico

>
>
>
> --
> 김 승 범 (SB Kim)
> New Media Literacy Education
> 010 - 2686 - 6855
> http://xenbio.net | http://smalltalk.kr
>
>


Reply | Threaded
Open this post in threaded view
|

Re: some strange when I call JS function from Amber

SeungBum Kim
I mean canvas has wrong selector for clearRect() in Amber. 

I think it should be something like 'clearRect:y:width:height:', isn't it?

-- SeungBum

On Wed, Oct 26, 2011 at 1:42 AM, Nicolas Petton <[hidden email]> wrote:

On Wed, 2011-10-26 at 01:08 +0900, SeungBum Kim wrote:
> Hi,
>
>
> I played with Amber today, and it was great
> fun. http://yfrog.com/nwytxp
>
> But I feel strange when I call JS function from Amber, such as canvas
> 'clearRect' function.
>
>
> Although argument for clearRect() is "float x, float y, float w, float
> h", I should call it with "clearRect:y:to:y:". "to:y:" for width and
> height.
>
>
> And using an array for the method doesn't work in Amber like 'canvas
> clearRect: #(0 0 10 10)'. I think I saw this kind of notation from
> somewhere. right?

yes, but this is old and has been changed. Sometimes it may feel strange
whith functions that take a lot of arguments, but most of the time it's
way better than using arrays as arguments.

Cheers,
Nico

>
>
>
> --
> 김 승 범 (SB Kim)
> New Media Literacy Education
> 010 - 2686 - 6855
> http://xenbio.net | http://smalltalk.kr
>
>





Reply | Threaded
Open this post in threaded view
|

Re: some strange when I call JS function from Amber

Nicolas Petton
On Wed, 2011-10-26 at 01:50 +0900, SeungBum Kim wrote:
> I mean canvas has wrong selector for clearRect() in Amber.
>
>
> I think it should be something like 'clearRect:y:width:height:', isn't
> it?

There's no selector for it, it just calls the JS.
function:clearRect:foo:bar:baz: would work too!

What amber does it converts the message send to a function call. For
keyword messages it will only keep the first keyword.

I should really improve the doc :)

Cheers,
Nico

>
>
> -- SeungBum
>
> On Wed, Oct 26, 2011 at 1:42 AM, Nicolas Petton
> <[hidden email]> wrote:
>        
>         On Wed, 2011-10-26 at 01:08 +0900, SeungBum Kim wrote:
>         > Hi,
>         >
>         >
>         > I played with Amber today, and it was great
>         > fun. http://yfrog.com/nwytxp
>         >
>         > But I feel strange when I call JS function from Amber, such
>         as canvas
>         > 'clearRect' function.
>         >
>         >
>         > Although argument for clearRect() is "float x, float y,
>         float w, float
>         > h", I should call it with "clearRect:y:to:y:". "to:y:" for
>         width and
>         > height.
>         >
>         >
>         > And using an array for the method doesn't work in Amber like
>         'canvas
>         > clearRect: #(0 0 10 10)'. I think I saw this kind of
>         notation from
>         > somewhere. right?
>        
>        
>         yes, but this is old and has been changed. Sometimes it may
>         feel strange
>         whith functions that take a lot of arguments, but most of the
>         time it's
>         way better than using arrays as arguments.
>        
>         Cheers,
>         Nico
>        
>        
>         >
>         >
>         >
>         > --
>         > 김 승 범 (SB Kim)
>         > New Media Literacy Education
>         > 010 - 2686 - 6855
>         > http://xenbio.net | http://smalltalk.kr
>         >
>         >
>        
>        
>        
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: some strange when I call JS function from Amber

SeungBum Kim
A-HA!! I got it.

I just read the code from other's examples and felt strange that t's using inconsistent selectors.

Thanks,
--SeungBum

On Wed, Oct 26, 2011 at 3:48 AM, Nicolas Petton <[hidden email]> wrote:
On Wed, 2011-10-26 at 01:50 +0900, SeungBum Kim wrote:
> I mean canvas has wrong selector for clearRect() in Amber.
>
>
> I think it should be something like 'clearRect:y:width:height:', isn't
> it?

There's no selector for it, it just calls the JS.
function:clearRect:foo:bar:baz: would work too!

What amber does it converts the message send to a function call. For
keyword messages it will only keep the first keyword.

I should really improve the doc :)

Cheers,
Nico

>
>
> -- SeungBum
>
> On Wed, Oct 26, 2011 at 1:42 AM, Nicolas Petton
> <[hidden email]> wrote:
>
>         On Wed, 2011-10-26 at 01:08 +0900, SeungBum Kim wrote:
>         > Hi,
>         >
>         >
>         > I played with Amber today, and it was great
>         > fun. http://yfrog.com/nwytxp
>         >
>         > But I feel strange when I call JS function from Amber, such
>         as canvas
>         > 'clearRect' function.
>         >
>         >
>         > Although argument for clearRect() is "float x, float y,
>         float w, float
>         > h", I should call it with "clearRect:y:to:y:". "to:y:" for
>         width and
>         > height.
>         >
>         >
>         > And using an array for the method doesn't work in Amber like
>         'canvas
>         > clearRect: #(0 0 10 10)'. I think I saw this kind of
>         notation from
>         > somewhere. right?
>
>
>         yes, but this is old and has been changed. Sometimes it may
>         feel strange
>         whith functions that take a lot of arguments, but most of the
>         time it's
>         way better than using arrays as arguments.
>
>         Cheers,
>         Nico
>
>
>         >
>         >
>         >
>         > --
>         > 김 승 범 (SB Kim)
>         > New Media Literacy Education
>         > 010 - 2686 - 6855
>         > http://xenbio.net | http://smalltalk.kr
>         >
>         >
>
>
>
>
>
>
>





Reply | Threaded
Open this post in threaded view
|

Re: some strange when I call JS function from Amber

Hannes Hirzel
Nicolas

A suggestion: Maybe you could use the canvas question of Kim and my
question regarding the file system functions (REPL thread) as an
example to illustrate the mapping of Amber methods to JavaScript
functions. Or put it the other way: in the case I have the Javascript
functions: how do I write the Amber selector?

--Hannes

On 10/26/11, SeungBum Kim <[hidden email]> wrote:

> A-HA!! I got it.
>
> I just read the code from other's examples and felt strange that t's using
> inconsistent selectors.
>
> Thanks,
> --SeungBum
>
> On Wed, Oct 26, 2011 at 3:48 AM, Nicolas Petton
> <[hidden email]>wrote:
>
>> On Wed, 2011-10-26 at 01:50 +0900, SeungBum Kim wrote:
>> > I mean canvas has wrong selector for clearRect() in Amber.
>> >
>> >
>> > I think it should be something like 'clearRect:y:width:height:', isn't
>> > it?
>>
>> There's no selector for it, it just calls the JS.
>> function:clearRect:foo:bar:baz: would work too!
>>
>> What amber does it converts the message send to a function call. For
>> keyword messages it will only keep the first keyword.
>>
>> I should really improve the doc :)
>>
>> Cheers,
>> Nico
>>
>> >
>> >
>> > -- SeungBum
>> >
>> > On Wed, Oct 26, 2011 at 1:42 AM, Nicolas Petton
>> > <[hidden email]> wrote:
>> >
>> >         On Wed, 2011-10-26 at 01:08 +0900, SeungBum Kim wrote:
>> >         > Hi,
>> >         >
>> >         >
>> >         > I played with Amber today, and it was great
>> >         > fun. http://yfrog.com/nwytxp
>> >         >
>> >         > But I feel strange when I call JS function from Amber, such
>> >         as canvas
>> >         > 'clearRect' function.
>> >         >
>> >         >
>> >         > Although argument for clearRect() is "float x, float y,
>> >         float w, float
>> >         > h", I should call it with "clearRect:y:to:y:". "to:y:" for
>> >         width and
>> >         > height.
>> >         >
>> >         >
>> >         > And using an array for the method doesn't work in Amber like
>> >         'canvas
>> >         > clearRect: #(0 0 10 10)'. I think I saw this kind of
>> >         notation from
>> >         > somewhere. right?
>> >
>> >
>> >         yes, but this is old and has been changed. Sometimes it may
>> >         feel strange
>> >         whith functions that take a lot of arguments, but most of the
>> >         time it's
>> >         way better than using arrays as arguments.
>> >
>> >         Cheers,
>> >         Nico
>> >
>> >
>> >         >
>> >         >
>> >         >
>> >         > --
>> >         > 김 승 범 (SB Kim)
>> >         > New Media Literacy Education
>> >         > 010 - 2686 - 6855
>> >         > http://xenbio.net | http://smalltalk.kr
>> >         >
>> >         >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>>
>>
>>
>