User-defined Objects

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

User-defined Objects

horrido
Something that From smalltalk to javascript and back doesn't address is how to deal with user-defined objects and their constructors. For example,

camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.innerHeight, 0.1, 1000 );

I can code part of this as:

camera := THREE PerspectiveCamera: 75 aspect: (window innerWidth)/(window innerHeight) near: 0.1 far: 1000.

But without 'new', is the object created? Syntactically, how do you do this?

--
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: User-defined Objects

Hannes Hirzel
Does this
http://stackoverflow.com/questions/23337995/how-do-i-translate-javascript-constructors-to-amber-smalltalk
help?

On 6/28/15, Richard Eng <[hidden email]> wrote:

> Something that From smalltalk to javascript and back
> <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>
> doesn't
> address is how to deal with user-defined objects and their constructors.
> For example,
>
> camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.
> innerHeight, 0.1, 1000 );
>
> I can code part of this as:
>
> camera := THREE PerspectiveCamera: 75 aspect: (window innerWidth)/(window
> innerHeight) near: 0.1 far: 1000.
>
> But without 'new', is the object created? Syntactically, how do you do
> this?
>
> --
> 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.
>

--
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: User-defined Objects

Herby Vojčík
In reply to this post by horrido


Dňa 28. júna 2015 17:22:42 CEST používateľ Richard Eng <[hidden email]> napísal:

> Something that From smalltalk to javascript and back
> <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>
> doesn't
> address is how to deal with user-defined objects and their
> constructors.
> For example,
>
> camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.
> innerHeight, 0.1, 1000 );
>
> I can code part of this as:
>
> camera := THREE PerspectiveCamera: 75 aspect: (window
> innerWidth)/(window
> innerHeight) near: 0.1 far: 1000.
>
> But without 'new', is the object created? Syntactically, how do you do
> this?

Syntactically, you don't.

Librarically, you use NativeFunction API.


--
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: User-defined Objects

Herby Vojčík


Dňa 28. júna 2015 18:09:12 CEST používateľ "Herby Vojčík" <[hidden email]> napísal:

>
>
> Dňa 28. júna 2015 17:22:42 CEST používateľ Richard Eng
> <[hidden email]> napísal:
> > Something that From smalltalk to javascript and back
> >
> <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>
> > doesn't
> > address is how to deal with user-defined objects and their
> > constructors.
> > For example,
> >
> > camera = new THREE.PerspectiveCamera( 75, window.innerWidth /
> window.
> > innerHeight, 0.1, 1000 );
> >
> > I can code part of this as:
> >
> > camera := THREE PerspectiveCamera: 75 aspect: (window
> > innerWidth)/(window
> > innerHeight) near: 0.1 far: 1000.
> >
> > But without 'new', is the object created? Syntactically, how do you
> do
> > this?
>
> Syntactically, you don't.
>
> Librarically, you use NativeFunction API.

Fixing myself: no, you use normal BlockClosure API: #new, #newValue: and the rest.

--
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: User-defined Objects

horrido
In reply to this post by Hannes Hirzel
Yes, I think this does help. But my example requires 4 arguments, and the best I can do with #newValue: is

camera := THREE PerspectiveCamera newValue: 75 value: (window innerWidth)/(window innerHeight) value: 0.1.

I need one more argument.


On Sunday, 28 June 2015 12:05:03 UTC-4, Hannes wrote:
Does this
<a href="http://stackoverflow.com/questions/23337995/how-do-i-translate-javascript-constructors-to-amber-smalltalk" target="_blank" rel="nofollow" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F23337995%2Fhow-do-i-translate-javascript-constructors-to-amber-smalltalk\46sa\75D\46sntz\0751\46usg\75AFQjCNFQoz_0edOLBcf6C8hE9WifQTsUZA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F23337995%2Fhow-do-i-translate-javascript-constructors-to-amber-smalltalk\46sa\75D\46sntz\0751\46usg\75AFQjCNFQoz_0edOLBcf6C8hE9WifQTsUZA';return true;">http://stackoverflow.com/questions/23337995/how-do-i-translate-javascript-constructors-to-amber-smalltalk
help?

On 6/28/15, Richard Eng <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="C9XliAFQL5kJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">horrido...@...> wrote:

> Something that From smalltalk to javascript and back
> <<a href="https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back" target="_blank" rel="nofollow" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\46sa\75D\46sntz\0751\46usg\75AFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\46sa\75D\46sntz\0751\46usg\75AFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw';return true;">https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>
> doesn't
> address is how to deal with user-defined objects and their constructors.
> For example,
>
> camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.
> innerHeight, 0.1, 1000 );
>
> I can code part of this as:
>
> camera := THREE PerspectiveCamera: 75 aspect: (window innerWidth)/(window
> innerHeight) near: 0.1 far: 1000.
>
> But without 'new', is the object created? Syntactically, how do you do
> this?
>
> --
> 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="C9XliAFQL5kJ" rel="nofollow" onmousedown="this.href='javascript:';return true;" onclick="this.href='javascript:';return true;">amber-lang+...@googlegroups.com.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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.
Reply | Threaded
Open this post in threaded view
|

Re: User-defined Objects

horrido
Okay, I got it. I just use #newWithValues:.


On Sunday, 28 June 2015 12:35:21 UTC-4, Richard Eng wrote:
Yes, I think this does help. But my example requires 4 arguments, and the best I can do with #newValue: is

camera := THREE PerspectiveCamera newValue: 75 value: (window innerWidth)/(window innerHeight) value: 0.1.

I need one more argument.


On Sunday, 28 June 2015 12:05:03 UTC-4, Hannes wrote:
Does this
<a href="http://stackoverflow.com/questions/23337995/how-do-i-translate-javascript-constructors-to-amber-smalltalk" rel="nofollow" target="_blank" onmousedown="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F23337995%2Fhow-do-i-translate-javascript-constructors-to-amber-smalltalk\46sa\75D\46sntz\0751\46usg\75AFQjCNFQoz_0edOLBcf6C8hE9WifQTsUZA';return true;" onclick="this.href='http://www.google.com/url?q\75http%3A%2F%2Fstackoverflow.com%2Fquestions%2F23337995%2Fhow-do-i-translate-javascript-constructors-to-amber-smalltalk\46sa\75D\46sntz\0751\46usg\75AFQjCNFQoz_0edOLBcf6C8hE9WifQTsUZA';return true;">http://stackoverflow.com/questions/23337995/how-do-i-translate-javascript-constructors-to-amber-smalltalk
help?

On 6/28/15, Richard Eng <[hidden email]> wrote:

> Something that From smalltalk to javascript and back
> <<a href="https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back" rel="nofollow" target="_blank" onmousedown="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\46sa\75D\46sntz\0751\46usg\75AFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw';return true;" onclick="this.href='https://www.google.com/url?q\75https%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\46sa\75D\46sntz\0751\46usg\75AFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw';return true;">https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>
> doesn't
> address is how to deal with user-defined objects and their constructors.
> For example,
>
> camera = new THREE.PerspectiveCamera( 75, window.innerWidth / window.
> innerHeight, 0.1, 1000 );
>
> I can code part of this as:
>
> camera := THREE PerspectiveCamera: 75 aspect: (window innerWidth)/(window
> innerHeight) near: 0.1 far: 1000.
>
> But without 'new', is the object created? Syntactically, how do you do
> this?
>
> --
> 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 <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href='https://groups.google.com/d/optout';return true;" onclick="this.href='https://groups.google.com/d/optout';return true;">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.