Can't use underscore character in amber?

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

Can't use underscore character in amber?

Jacob Wagner
Hi, I am trying to replicate the following javascript code:

stage.addEventListener(KeyboardEvent.KEY_DOWN, onKD);

function onKD (e)
34          { 
35               console.log(e.keyCode);
36               if(e.keyCode == 37) l = true;
37               if(e.keyCode == 38) u = true;
38               if(e.keyCode == 39) r = true;
39               if(e.keyCode == 40) d = true;
40          }


However I am having problems.  If I try KeyboardEvent KEY_DOWN  and inspect it in an amber workspace, I get an error about an unexpected character: underscore.  

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
<zenchess@gmail.com>
Reply | Threaded
Open this post in threaded view
|

Re: Can't use underscore character in amber?

Bernat Romagosa

Hi there!

Thy with KeyboardEvent at: 'KEY_DOWN', I believe this should work.

Cheers,
Bernat.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Can't use underscore character in amber?

Jacob Wagner
I tried that, and it brings up a smalltalk error: blockclosure does not understand at:

On Thursday, November 12, 2015 at 12:54:30 AM UTC-6, Bernat Romagosa wrote:

Hi there!

Thy with KeyboardEvent at: 'KEY_DOWN', I believe this should work.

Cheers,
Bernat.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
<zenchess@gmail.com>
Reply | Threaded
Open this post in threaded view
|

Re: Can't use underscore character in amber?

Bernat Romagosa
Hmmm I see... can you share the whole project so we can tinker a little bit?

2015-11-12 23:46 GMT+01:00 Zenchess <[hidden email]>:
I tried that, and it brings up a smalltalk error: blockclosure does not understand at:


On Thursday, November 12, 2015 at 12:54:30 AM UTC-6, Bernat Romagosa wrote:

Hi there!

Thy with KeyboardEvent at: 'KEY_DOWN', I believe this should work.

Cheers,
Bernat.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.



--
Bernat Romagosa.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Can't use underscore character in amber?

Herby Vojčík
In reply to this post by Jacob Wagner
BlockClosure is a Smalltalk-level object (that's the problem when JS
functions are used to contains other properties; why is KeyboardEvent a
function, BTW?). What you want to access, are JS-level properties.

There are three ways:
1. use low-level accessor: Foo basicAt: 'KEY_DOWN'.
2. temporarily wrap it in JS proxy: (JSObjectProxy on: Foo) at: 'KEY_DOWN'.
3. permanently remove Smalltalkiness: Smalltalk optOut: Foo, after which
you can treat it as raw JS value and use Foo at: 'KEY_DOWN'.

Herby

P.S.: Just FYI, 3. can be reverted by Smalltalk cancelOptOut: Foo.

P.P.S.: There's an ages old issue to allow underscore in identifiers:
https://github.com/amber-smalltalk/amber/issues/20

Zenchess wrote:

> I tried that, and it brings up a smalltalk error: blockclosure does not
> understand at:
>
> On Thursday, November 12, 2015 at 12:54:30 AM UTC-6, Bernat Romagosa wrote:
>
>     Hi there!
>
>     Thy with KeyboardEvent at: 'KEY_DOWN', I believe this should work.
>
>     Cheers,
>     Bernat.
>
> --
> You received this message because you are subscribed to the Google
> Groups "amber-lang" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to [hidden email]
> <mailto:[hidden email]>.
> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "amber-lang" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.