Using Amber with Simile Timeline

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

Using Amber with Simile Timeline

Andy Burnett
Just forking the thread here ;-)

Andrew, can you give us any example code on what you got working?  I would love to see some examples.

Cheers
Andy

On Thu, May 3, 2012 at 12:18 PM, Andrew McQuiggin <[hidden email]> wrote:

I do like how it works currently.

But it took me some time to discover what is possible and the correct usage. For example, the need to use local rather than instance variables when passing parameters from Smalltalk to Javascript.  Examples on the wiki would make it easier to pick up.

To try it out for myself I built a simple example of manipulating the Simile Timeline. It was easy (and fun), once I understood the usage.

Andrew

On May 3, 2012 4:57 PM, "Nicolas Petton" <[hidden email]> wrote:
Herby Vojčík <[hidden email]> writes:

Hi!

IMHO it's fine the way it is, as it allows you to seemlessly send
messages to JavaScript objects without any additional effort.

I very much like the fact that you can do `console log: hello` or even
`window document inspect`. It just works.

Now, what do others think about it?


BTW, the IDE will warn you about unknown variables.

Cheers,
Nico

> Hello,
>
> I see unknown variable as a bit of a problem (unknown variables are
> console and z and partially also Capitalized and Array from this code:
> foo: x
> |y|
>       y:=42.
>       console log: (z:=x+y).
>       ^Capitalized with: Array new
> ).
>
> This produces roughly:
> function foo(x) {var y=nil;
> y=42;
> send((console == null ? nil : console), "_log_", [z=x+y]);
> return (send((smalltalk.Capitalized || Capitalized), "_with_",
> [send((smalltalk.Array || Array), "_new", [])]);
> }
>
> You see console and z are used as-is (sanitized when used as a
> receiver), capitalized ones are used primarily as smalltalk classes
> but allow fallback (BTW, not sanitized).
>
> I'd propose ban unknown variables and require explicit importing them
> into method, by simple (ab)use of <inlineJs> facility:
>
> foo:x
> |y|
> <console;z;Capitalized>
>
>       y:=42.
>       console log: (z:=x+y).
>       ^Capitalized with: Array new
>
> which would produce:
>
> function(x) {var y=nil;
> // will use console, z and Capitalized as globals
> // rest is error when camelCase and class in PascalCase
> // the code _can_ in fact be generated, it needs to be no special:
> ;{console;z;Capitalized}
> y=42;
> send((console == null ? nil : console), "_log_", [z=x+y]);
> return (Capitalized == null ? nil : Capitalized), "_with_",
> [send(smalltalk.Array, "_new", [])]);
> }
>
> That is, if code inside <> contains _only_ list of identifiers
> separated by semicolon, it hints the compiler which variables from
> outer world to use (and reject others).
>
> The question is, would amber users be willing to adopt this
> restriction (and also, do you see it as good thing at all (I see))?
>
> Herby

Reply | Threaded
Open this post in threaded view
|

Re: Using Amber with Simile Timeline

Andrew McQuiggin
Sure, happy to - I intend to clean it up and share it (screenshot for now), much as I have with the PhoneGap trial I did. I picked the Simile Timeline as it's familiar to many of us, and it's so useful. I've only used Javascript a little, and I've certainly not got expertise in language implementation. So just getting on a trying to wrap some of a Javascript api was an instructive exercise. Once I've shared it I hope Nico and others can improve it to become an example.

Andrew

On 3 May 2012 18:50, Andy Burnett <[hidden email]> wrote:
Just forking the thread here ;-)

Andrew, can you give us any example code on what you got working?  I would love to see some examples.

Cheers
Andy

On Thu, May 3, 2012 at 12:18 PM, Andrew McQuiggin <[hidden email]> wrote:

I do like how it works currently.

But it took me some time to discover what is possible and the correct usage. For example, the need to use local rather than instance variables when passing parameters from Smalltalk to Javascript.  Examples on the wiki would make it easier to pick up.

To try it out for myself I built a simple example of manipulating the Simile Timeline. It was easy (and fun), once I understood the usage.

Andrew

On May 3, 2012 4:57 PM, "Nicolas Petton" <[hidden email]> wrote:
Herby Vojčík <[hidden email]> writes:

Hi!

IMHO it's fine the way it is, as it allows you to seemlessly send
messages to JavaScript objects without any additional effort.

I very much like the fact that you can do `console log: hello` or even
`window document inspect`. It just works.

Now, what do others think about it?


BTW, the IDE will warn you about unknown variables.

Cheers,
Nico

> Hello,
>
> I see unknown variable as a bit of a problem (unknown variables are
> console and z and partially also Capitalized and Array from this code:
> foo: x
> |y|
>       y:=42.
>       console log: (z:=x+y).
>       ^Capitalized with: Array new
> ).
>
> This produces roughly:
> function foo(x) {var y=nil;
> y=42;
> send((console == null ? nil : console), "_log_", [z=x+y]);
> return (send((smalltalk.Capitalized || Capitalized), "_with_",
> [send((smalltalk.Array || Array), "_new", [])]);
> }
>
> You see console and z are used as-is (sanitized when used as a
> receiver), capitalized ones are used primarily as smalltalk classes
> but allow fallback (BTW, not sanitized).
>
> I'd propose ban unknown variables and require explicit importing them
> into method, by simple (ab)use of <inlineJs> facility:
>
> foo:x
> |y|
> <console;z;Capitalized>
>
>       y:=42.
>       console log: (z:=x+y).
>       ^Capitalized with: Array new
>
> which would produce:
>
> function(x) {var y=nil;
> // will use console, z and Capitalized as globals
> // rest is error when camelCase and class in PascalCase
> // the code _can_ in fact be generated, it needs to be no special:
> ;{console;z;Capitalized}
> y=42;
> send((console == null ? nil : console), "_log_", [z=x+y]);
> return (Capitalized == null ? nil : Capitalized), "_with_",
> [send(smalltalk.Array, "_new", [])]);
> }
>
> That is, if code inside <> contains _only_ list of identifiers
> separated by semicolon, it hints the compiler which variables from
> outer world to use (and reject others).
>
> The question is, would amber users be willing to adopt this
> restriction (and also, do you see it as good thing at all (I see))?
>
> Herby