Creating literal array

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

Creating literal array

Eno
Hi, all

   I'm using Amber Smalltalk client web programming for a while.

   I found there are situations that I needed to transform js codes into Smalltalk equivalents.

   I could use <......> to inline js codes for current version. Arrays are another thing that need to be class data and are frequently needed, so some fast transformation needed.

    There is a dictionary usage like #{'name' -> 'id', .... }, is there better ways to transform js array, like

var colors = ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
using some sort of literal expression like dictionary does to easily transform that array structure without using using Array#add:... methods?

 

--
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/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

Herby Vojčík


TsunKuo Kuo wrote:

> There is a dictionary usage like #{'name' -> 'id', .... }, is there
> better ways to transform js array, like
>
>
> var colors =
> ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>
>
> using some sort of literal expression like dictionary does to easily
> transform that array structure without using using Array#add:... methods?

What's wrong with plain Smalltalk literal array #('fff' '000' ...) ?

--
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/groups/opt_out.
Eno
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

Eno
Herby,

   Thanks, I got it.
   I forgot that way, long time not on Smalltalk ( Dolphin dialect) after it went to no revision and support. .
   Amber is great,  js packages could be included smoothly as I've tried upon Firebase.js without much problem so far except that tranforming complicated js codes of it's examples to smalltalk ones caused a lot of effort, It would be better they are writted by the good hands as tutorials.

   Hope to see more js packages included and fully wrapped or integrated. 

Best regargs.

Tgkuo

Herby於 2013年8月15日星期四UTC+8下午6時14分14秒寫道:


TsunKuo Kuo wrote:

> There is a dictionary usage like #{'name' -> 'id', .... }, is there
> better ways to transform js array, like
>
>
> var colors =
> ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>
>
> using some sort of literal expression like dictionary does to easily
> transform that array structure without using using Array#add:... methods?

What's wrong with plain Smalltalk literal array #('fff' '000' ...) ?

--
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/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

kilon.alios
The goal behind amber is not only bring smalltalk on top of js but map smalltalk on js, so that you wont have to use wrappers to use js libraries. Any js library will be a smalltalk library automatically. 

So technically you dont need more js packages included and fully wrapped or integrated with amber. 


On Thu, Aug 15, 2013 at 1:47 PM, TsunKuo Kuo <[hidden email]> wrote:
Herby,

   Thanks, I got it.
   I forgot that way, long time not on Smalltalk ( Dolphin dialect) after it went to no revision and support. .
   Amber is great,  js packages could be included smoothly as I've tried upon Firebase.js without much problem so far except that tranforming complicated js codes of it's examples to smalltalk ones caused a lot of effort, It would be better they are writted by the good hands as tutorials.

   Hope to see more js packages included and fully wrapped or integrated. 

Best regargs.

Tgkuo

Herby於 2013年8月15日星期四UTC+8下午6時14分14秒寫道:


TsunKuo Kuo wrote:

> There is a dictionary usage like #{'name' -> 'id', .... }, is there
> better ways to transform js array, like
>
>
> var colors =
> ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>
>
> using some sort of literal expression like dictionary does to easily
> transform that array structure without using using Array#add:... methods?

What's wrong with plain Smalltalk literal array #('fff' '000' ...) ?

--
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/groups/opt_out.

--
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/groups/opt_out.
Eno
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

Eno
Hi, kilon,

    I think that I understand what the goal behind amber that you mentioned, if it is not wrong:

   Leave the examples or any html/js scripts as they are, build Amber Smalltalk on it, link the DOM element via jQuery and manipulate them at will without bothering for any transformations. That way I could make use of the full power of original js/html already given and enhance it at my will via Amber Smalltalk.....

Thanks.

Best,

Tgkuo

kilon alios於 2013年8月15日星期四UTC+8下午9時41分05秒寫道:
The goal behind amber is not only bring smalltalk on top of js but map smalltalk on js, so that you wont have to use wrappers to use js libraries. Any js library will be a smalltalk library automatically. 

So technically you dont need more js packages included and fully wrapped or integrated with amber. 


On Thu, Aug 15, 2013 at 1:47 PM, TsunKuo Kuo <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="WBkfmZi-urUJ">tgk...@...> wrote:
Herby,

   Thanks, I got it.
   I forgot that way, long time not on Smalltalk ( Dolphin dialect) after it went to no revision and support. .
   Amber is great,  js packages could be included smoothly as I've tried upon Firebase.js without much problem so far except that tranforming complicated js codes of it's examples to smalltalk ones caused a lot of effort, It would be better they are writted by the good hands as tutorials.

   Hope to see more js packages included and fully wrapped or integrated. 

Best regargs.

Tgkuo

Herby於 2013年8月15日星期四UTC+8下午6時14分14秒寫道:


TsunKuo Kuo wrote:

> There is a dictionary usage like #{'name' -> 'id', .... }, is there
> better ways to transform js array, like
>
>
> var colors =
> ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>
>
> using some sort of literal expression like dictionary does to easily
> transform that array structure without using using Array#add:... methods?

What's wrong with plain Smalltalk literal array #('fff' '000' ...) ?

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="WBkfmZi-urUJ">amber-lang+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

kilon.alios
yes but you also can generate hmtl elements from amber , for example go to Package : Canvas Class: HTMLCanvas , you will find many HTML tags you can use to generate HTML. In this case amber uses jquery and js to generate hmtl elements. So you could replace JS , HTML and even CSS with amber. Which solves on the problems that make me hate web development, fragmentation.

So its possible to make a web site / web app completely using just amber and nothing else. Though amber is not perfect so its will be likely you will need to do some hmlt and css , or use web backends like Seaside the more demanding you get. But then what is perfect ;)  


On Thu, Aug 15, 2013 at 5:57 PM, TsunKuo Kuo <[hidden email]> wrote:
Hi, kilon,

    I think that I understand what the goal behind amber that you mentioned, if it is not wrong:

   Leave the examples or any html/js scripts as they are, build Amber Smalltalk on it, link the DOM element via jQuery and manipulate them at will without bothering for any transformations. That way I could make use of the full power of original js/html already given and enhance it at my will via Amber Smalltalk.....

Thanks.

Best,

Tgkuo

kilon alios於 2013年8月15日星期四UTC+8下午9時41分05秒寫道:
The goal behind amber is not only bring smalltalk on top of js but map smalltalk on js, so that you wont have to use wrappers to use js libraries. Any js library will be a smalltalk library automatically. 

So technically you dont need more js packages included and fully wrapped or integrated with amber. 


On Thu, Aug 15, 2013 at 1:47 PM, TsunKuo Kuo <[hidden email]> wrote:
Herby,

   Thanks, I got it.
   I forgot that way, long time not on Smalltalk ( Dolphin dialect) after it went to no revision and support. .
   Amber is great,  js packages could be included smoothly as I've tried upon Firebase.js without much problem so far except that tranforming complicated js codes of it's examples to smalltalk ones caused a lot of effort, It would be better they are writted by the good hands as tutorials.

   Hope to see more js packages included and fully wrapped or integrated. 

Best regargs.

Tgkuo

Herby於 2013年8月15日星期四UTC+8下午6時14分14秒寫道:


TsunKuo Kuo wrote:

> There is a dictionary usage like #{'name' -> 'id', .... }, is there
> better ways to transform js array, like
>
>
> var colors =
> ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>
>
> using some sort of literal expression like dictionary does to easily
> transform that array structure without using using Array#add:... methods?

What's wrong with plain Smalltalk literal array #('fff' '000' ...) ?

--
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 amber-lang+...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
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/groups/opt_out.

--
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/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

Andy Burnett
In reply to this post by Eno
I am interested that you have tried firebase. I have been experimenting with that too. Are you loading it via jquery ( through amber ) or are you just including it within the HTML of the page?

On 15 Aug 2013, at 06:47, TsunKuo Kuo <[hidden email]> wrote:

Herby,

   Thanks, I got it.
   I forgot that way, long time not on Smalltalk ( Dolphin dialect) after it went to no revision and support. .
   Amber is great,  js packages could be included smoothly as I've tried upon Firebase.js without much problem so far except that tranforming complicated js codes of it's examples to smalltalk ones caused a lot of effort, It would be better they are writted by the good hands as tutorials.

   Hope to see more js packages included and fully wrapped or integrated. 

Best regargs.

Tgkuo

Herby於 2013年8月15日星期四UTC+8下午6時14分14秒寫道:


TsunKuo Kuo wrote:

> There is a dictionary usage like #{'name' -> 'id', .... }, is there
> better ways to transform js array, like
>
>
> var colors =
> ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>
>
> using some sort of literal expression like dictionary does to easily
> transform that array structure without using using Array#add:... methods?

What's wrong with plain Smalltalk literal array #('fff' '000' ...) ?

--
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/groups/opt_out.

--
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/groups/opt_out.
Eno
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

Eno
Loading within HTML is ok

Loading through amber need some trick:
as I write the initialize method below:

initialize
  jQuery getScript: 'https://cdn.firebase.com/v0/firebase.js'.
  self appendToJQuery: 'body' asJQuery.
  [ Firebase isNil ] whileTrue.
  dataRef := Firebase newValue: 'https://enox1.firebaseio.com/examples/firebase'.
  super initialize.

I need to make sure Firebase.js is loaded and ready to use, so, I use   [ Firebase isNil ] whileTrue. to wait for it.

Are there other better way for the synchronization?

Best,

Tgkuo




Andy Burnett於 2013年8月16日星期五UTC+8上午5時30分11秒寫道:
I am interested that you have tried firebase. I have been experimenting with that too. Are you loading it via jquery ( through amber ) or are you just including it within the HTML of the page?

On 15 Aug 2013, at 06:47, TsunKuo Kuo <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="-65yAIFeQ4QJ">tgk...@...> wrote:

Herby,

   Thanks, I got it.
   I forgot that way, long time not on Smalltalk ( Dolphin dialect) after it went to no revision and support. .
   Amber is great,  js packages could be included smoothly as I've tried upon Firebase.js without much problem so far except that tranforming complicated js codes of it's examples to smalltalk ones caused a lot of effort, It would be better they are writted by the good hands as tutorials.

   Hope to see more js packages included and fully wrapped or integrated. 

Best regargs.

Tgkuo

Herby於 2013年8月15日星期四UTC+8下午6時14分14秒寫道:


TsunKuo Kuo wrote:

> There is a dictionary usage like #{'name' -> 'id', .... }, is there
> better ways to transform js array, like
>
>
> var colors =
> ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>
>
> using some sort of literal expression like dictionary does to easily
> transform that array structure without using using Array#add:... methods?

What's wrong with plain Smalltalk literal array #('fff' '000' ...) ?

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="-65yAIFeQ4QJ">amber-lang+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
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/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

Herby Vojčík
I don't know firebase, maybe it loads in another thread somehow magically, but JS (and therefore, amber) is single-threaded, so the above should not work at all - either is trye at first try, or it loops forever.

You should start code asynchronously (valueWIthTimeout:, valueWithInterval: or if you really want it asap, fork).

Herby

TsunKuo Kuo wrote:

> Loading within HTML is ok
>
> Loading through amber need some trick:
> as I write the initialize method below:
>
> initialize
> jQuery getScript: 'https://cdn.firebase.com/v0/firebase.js'.
> self appendToJQuery: 'body' asJQuery.
> [ Firebase isNil ] whileTrue.
> dataRef := Firebase newValue:
> 'https://enox1.firebaseio.com/examples/firebase'.
> super initialize.
>
> I need to make sure Firebase.js is loaded and ready to use, so, I use
> [ Firebase isNil ] whileTrue. to wait for it.
>
> Are there other better way for the synchronization?
>
> Best,
>
> Tgkuo
>
>
>
>
> Andy Burnett於 2013年8月16日星期五UTC+8上午5時30
分11秒寫道:

>
>     I am interested that you have tried firebase. I have been
>     experimenting with that too. Are you loading it via jquery (
>     through amber ) or are you just including it within the HTML of
>     the page?
>
>     On 15 Aug 2013, at 06:47, TsunKuo Kuo <[hidden email]
>     <javascript:>> wrote:
>
>>     Herby,
>>
>>     Thanks, I got it.
>>     I forgot that way, long time not on Smalltalk ( Dolphin dialect)
>>     after it went to no revision and support. .
>>     Amber is great, js packages could be included smoothly as I've
>>     tried upon Firebase.js without much problem so far except that
>>     tranforming complicated js codes of it's examples to smalltalk
>>     ones caused a lot of effort, It would be better they are writted
>>     by the good hands as tutorials.
>>
>>     Hope to see more js packages included and fully wrapped or
>>     integrated.
>>
>>     Best regargs.
>>
>>     Tgkuo
>>
>>     Herby於 2013年8月15日星期四U
TC+8下午6時14分14秒寫道:

>>
>>
>>
>>         TsunKuo Kuo wrote:
>>         > There is a dictionary usage like #{'name' -> 'id', .... },
>>         is there
>>         > better ways to transform js array, like
>>         >
>>         >
>>         > var colors =
>>         >
>>         ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>>
>>         >
>>         >
>>         > using some sort of literal expression like dictionary does
>>         to easily
>>         > transform that array structure without using using
>>         Array#add:... methods?
>>
>>         What's wrong with plain Smalltalk literal array #('fff' '000'
>>         ...) ?
>>
>>     --
>>     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] <javascript:>.
>>     For more o
ptions, visit https://groups.google.com/groups/opt_out
>>     <https://groups.google.com/groups/opt_out>.
>
> --
> 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/groups/opt_out.

--
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/groups/opt_out.
Eno
Reply | Threaded
Open this post in threaded view
|

Re: Creating literal array

Eno

After studying the amber cookbook recipe, I found the way to do it  by the jquery function: jQuery getScript:onSuccess:

 initialize
     jQuery getScript: 'https://cdn.firebase.com/v0/firebase.js'
        onSuccess:  [ dataRef := Firebase newValue: 'https://enox1.firebaseio.com/examples/firebase' ].

:)


Herby於 2013年8月16日星期五UTC+8下午8時24分18秒寫道:
I don't know firebase, maybe it loads in another thread somehow magically, but JS (and therefore, amber) is single-threaded, so the above should not work at all - either is trye at first try, or it loops forever.

You should start code asynchronously (valueWIthTimeout:, valueWithInterval: or if you really want it asap, fork).

Herby

TsunKuo Kuo wrote:

> Loading within HTML is ok
>
> Loading through amber need some trick:
> as I write the initialize method below:
>
> initialize
> jQuery getScript: 'https://cdn.firebase.com/v0/firebase.js'.
> self appendToJQuery: 'body' asJQuery.
> [ Firebase isNil ] whileTrue.
> dataRef := Firebase newValue:
> 'https://enox1.firebaseio.com/examples/firebase'.
> super initialize.
>
> I need to make sure Firebase.js is loaded and ready to use, so, I use
> [ Firebase isNil ] whileTrue. to wait for it.
>
> Are there other better way for the synchronization?
>
> Best,
>
> Tgkuo
>
>
>
>
> Andy Burnett於 2013年8月16日星期五UTC+8上午5時30
分11秒寫道:

>
>     I am interested that you have tried firebase. I have been
>     experimenting with that too. Are you loading it via jquery (
>     through amber ) or are you just including it within the HTML of
>     the page?
>
>     On 15 Aug 2013, at 06:47, TsunKuo Kuo <[hidden email]
>     <javascript:>> wrote:
>
>>     Herby,
>>
>>     Thanks, I got it.
>>     I forgot that way, long time not on Smalltalk ( Dolphin dialect)
>>     after it went to no revision and support. .
>>     Amber is great, js packages could be included smoothly as I've
>>     tried upon Firebase.js without much problem so far except that
>>     tranforming complicated js codes of it's examples to smalltalk
>>     ones caused a lot of effort, It would be better they are writted
>>     by the good hands as tutorials.
>>
>>     Hope to see more js packages included and fully wrapped or
>>     integrated.
>>
>>     Best regargs.
>>
>>     Tgkuo
>>
>>     Herby於 2013年8月15日星期四U
TC+8下午6時14分14秒寫道:

>>
>>
>>
>>         TsunKuo Kuo wrote:
>>         > There is a dictionary usage like #{'name' -> 'id', .... },
>>         is there
>>         > better ways to transform js array, like
>>         >
>>         >
>>         > var colors =
>>         >
>>         ["fff","000","f00","0f0","00f","88f","f8d","f88","f05","f80","0f8","cf0","08f","408","ff8","8ff"];
>>
>>         >
>>         >
>>         > using some sort of literal expression like dictionary does
>>         to easily
>>         > transform that array structure without using using
>>         Array#add:... methods?
>>
>>         What's wrong with plain Smalltalk literal array #('fff' '000'
>>         ...) ?
>>
>>     --
>>     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 amber-lang+...@googlegroups.com <javascript:>.
>>     For more o
ptions, visit https://groups.google.com/groups/opt_out
>>     <https://groups.google.com/groups/opt_out>.
>
> --
> 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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="A8BqajXplqEJ">amber-lang+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
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/groups/opt_out.