self['@name']

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

self['@name']

horrido
I have an app with the following class:

Object subclass: #Stressrelief
 instanceVariableNames
: 'mySound currentTrack tracks mute cursor images scheduled'
 
package: 'Stressrelief'

I'm trying to access mySound from within JavaScript. Just to verify access, I pop up an alert:

alert('mySound is '+self['@mySound']);

Everywhere in my code, it tells me that "mySound is undefined". What have I missed from this document, "From smalltalk to javascript and back"?

--
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: self['@name']

Herby Vojčík
Richard Eng wrote:

> I have an app with the following class:
>
> ||
> Objectsubclass:#Stressrelief
>  instanceVariableNames:'mySound currentTrack tracks mute cursor images
> scheduled'
> package:'Stressrelief'
>
> I'm trying to access mySound from within JavaScript. Just to verify
> access, I pop up an alert:
>
> ||
> alert('mySound is '+self['@mySound']);

Well, this seems to be ok. Not to mentioned the error message "mySound is undefined" refers to 'mySound'. not '@mySound'. Is it the error message regarding that alert? Is that alert in the JS type method (there is no online JS inside ST any more, for maybe three years - inline JS only work in dedicated JS method.

Or is it that you have:

<inlineJS: ' alert('mySound is '+self['@mySound']);'>

In which case the apostrophe ends the string, thus it does not fit into parse rule for new inlineJS, so it represents it as legacy JS statement of:

  inlineJS: 'alert'; // inlineJS in JS label
  mySound; // here it should have blow
n with 'ReferenceError: mySound is undefined'
  is;
  '+ self';
  @mySound; // well, this is really strange in JS and would blow but did not get there
  ']);';

Seems likely. The inlineJS: '....' needs '....' to be proper Smalltalk string and nothing else should be present there. So either using two apostrophes to escape it or use quote.

>
> Everywhere in my code, it tells me that "mySound is undefined". What
> have I missed from this document, "From smalltalk to javascript and
> back
> <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>"?
>
> --
> 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.
Reply | Threaded
Open this post in threaded view
|

Re: self['@name']

Herby Vojčík
Herby Vojčík wrote:

> Richard Eng wrote:
>> I have an app with the following class:
>>
>> ||
>> Objectsubclass:#Stressrelief
>> instanceVariableNames:'mySound currentTrack tracks mute cursor images
>> scheduled'
>> package:'Stressrelief'
>>
>> I'm trying to access mySound from within JavaScript. Just to verify
>> access, I pop up an alert:
>>
>> ||
>> alert('mySound is '+self['@mySound']);
>
> Well, this seems to be ok. Not to mentioned the error message "mySound
> is undefined" refers to 'mySound'. not '@mySound'. Is it the error
> message regarding that alert? Is that alert in the JS type method (there
> is no online JS inside ST any more, for maybe three years - inline JS
> only work in dedicated JS method.
>
> Or is it that you have:
>
> <inlineJS: ' alert('mySound is '+self['@mySound']);'>
>
> In which case the apostrophe ends the string, thus it does not fit into
> parse rule for new inlineJS, so it represents it as legacy JS statement of:

BTW, whenever parser parses legacy form of JS, it does console.warn. So
you should have had the warning in JS console.

> inlineJS: 'alert'; // inlineJS in JS label
> mySound; // here it should have blow
> n with 'ReferenceError: mySound is undefined'
> is;
> '+ self';
> @mySound; // well, this is really strange in JS and would blow but did
> not get there
> ']);';
>
> Seems likely. The inlineJS: '....' needs '....' to be proper Smalltalk
> string and nothing else should be present there. So either using two
> apostrophes to escape it or use quote.
>
>>
>> Everywhere in my code, it tells me that "mySound is undefined". What
>> have I missed from this document, "From smalltalk to javascript and
>> back
>> <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>"?
>>
>>
>> --
>> 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.
Reply | Threaded
Open this post in threaded view
|

Re: self['@name']

Herby Vojčík
In reply to this post by Herby Vojčík
Herby Vojčík wrote:

> Richard Eng wrote:
>> I have an app with the following class:
>>
>> ||
>> Objectsubclass:#Stressrelief
>> instanceVariableNames:'mySound currentTrack tracks mute cursor images
>> scheduled'
>> package:'Stressrelief'
>>
>> I'm trying to access mySound from within JavaScript. Just to verify
>> access, I pop up an alert:
>>
>> ||
>> alert('mySound is '+self['@mySound']);
>
> Well, this seems to be ok. Not to mentioned the error message "mySound
> is undefined" refers to 'mySound'. not '@mySound'. Is it the error
> message regarding that alert? Is that alert in the JS type method (there
> is no online JS inside ST any more, for maybe three years - inline JS
> only work in dedicated JS method.
>
> Or is it that you have:
>
> <inlineJS: ' alert('mySound is '+self['@mySound']);'>
>
> In which case the apostrophe ends the string, thus it does not fit into
> parse rule for new inlineJS, so it represents it as legacy JS statement of:

I knew beforehand this is the caveat and may happen. Maybe I should
tighten the legacyJavaScriptStatement rule in parse to not accept
anything that begins with 'inlineJS', so this kind of error fails fast...

>
> inlineJS: 'alert'; // inlineJS in JS label
> mySound; // here it should have blow
> n with 'ReferenceError: mySound is undefined'
> is;
> '+ self';
> @mySound; // well, this is really strange in JS and would blow but did
> not get there
> ']);';
>
> Seems likely. The inlineJS: '....' needs '....' to be proper Smalltalk
> string and nothing else should be present there. So either using two
> apostrophes to escape it or use quote.
>
>>
>> Everywhere in my code, it tells me that "mySound is undefined". What
>> have I missed from this document, "From smalltalk to javascript and
>> back
>> <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>"?
>>
>>
>> --
>> 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.
Reply | Threaded
Open this post in threaded view
|

Re: self['@name']

horrido
In reply to this post by Herby Vojčík
I have a separate JS file containing special routines I need: <script type="text/javascript" src="js/index.js"></script>


On Monday, 21 November 2016 15:03:51 UTC-5, Herby wrote:
Richard Eng wrote:

> I have an app with the following class:
>
> ||
> Objectsubclass:#Stressrelief
>  instanceVariableNames:'mySound currentTrack tracks mute cursor images
> scheduled'
> package:'Stressrelief'
>
> I'm trying to access mySound from within JavaScript. Just to verify
> access, I pop up an alert:
>
> ||
> alert('mySound is '+self['@mySound']);

Well, this seems to be ok. Not to mentioned the error message "mySound is undefined" refers to 'mySound'. not '@mySound'. Is it the error message regarding that alert? Is that alert in the JS type method (there is no online JS inside ST any more, for maybe three years - inline JS only work in dedicated JS method.

Or is it that you have:

<inlineJS: ' alert('mySound is '+self['@mySound']);'>

In which case the apostrophe ends the string, thus it does not fit into parse rule for new inlineJS, so it represents it as legacy JS statement of:

  inlineJS: 'alert'; // inlineJS in JS label
  mySound; // here it should have blow
n with 'ReferenceError: mySound is undefined'
  is;
  '+ self';
  @mySound; // well, this is really strange in JS and would blow but did not get there
  ']);';

Seems likely. The inlineJS: '....' needs '....' to be proper Smalltalk string and nothing else should be present there. So either using two apostrophes to escape it or use quote.

>
> Everywhere in my code, it tells me that "mySound is undefined". What
> have I missed from this document, "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=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw&#39;;return true;">https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>"?
>
> --
> 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="h6C5TZz-AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+...@googlegroups.com
> <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="h6C5TZz-AwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+unsubscribe@...>.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;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: self['@name']

Herby Vojčík
Richard Eng wrote:
> I have a separate JS file containing special routines I need: <script
> type="text/javascript" src="js/index.js"></script>

Well, then you do something wrong. How do you want to use 'self' outside
of the method?

>
>
> On Monday, 21 November 2016 15:03:51 UTC-5, Herby wrote:
>
>     Richard Eng wrote:
>      > I have an app with the following class:
>      >
>      > ||
>      > Objectsubclass:#Stressrelief
>      >  instanceVariableNames:'mySound currentTrack tracks mute cursor
>     images
>      > scheduled'
>      > package:'Stressrelief'
>      >
>      > I'm trying to access mySound from within JavaScript. Just to verify
>      > access, I pop up an alert:
>      >
>      > ||
>      > alert('mySound is '+self['@mySound']);
>
>     Well, this seems to be ok. Not to mentioned the error message
>     "mySound is undefined" refers to 'mySound'. not '@mySound'. Is it
>     the error message regarding that alert? Is that alert in the JS type
>     method (there is no online JS inside ST any more, for maybe three
>     years - inline JS only work in dedicated JS method.
>
>     Or is it that you have:
>
>     <inlineJS: ' alert('mySound is '+self['@mySound']);'>
>
>     In which case the apostrophe ends the string, thus it does not fit
>     into parse rule for new inlineJS, so it represents it as legacy JS
>     statement of:
>
>        inlineJS: 'alert'; // inlineJS in JS label
>        mySound; // here it should have blow
>     n with 'ReferenceError: mySound is undefined'
>        is;
>     '+ self';
>        @mySound; // well, this is really strange in JS and would blow
>     but did not get there
>     ']);';
>
>     Seems likely. The inlineJS: '....' needs '....' to be proper
>     Smalltalk string and nothing else should be present there. So either
>     using two apostrophes to escape it or use quote.
>
>      >
>      > Everywhere in my code, it tells me that "mySound is undefined". What
>      > have I missed from this document, "From smalltalk to javascript and
>      > back
>      >
>     <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back
>     <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>>"?
>
>      >
>      > --
>      > 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:>
>      > <mailto:[hidden email] <javascript:>>.
>      > For more options, visit https://groups.google.com/d/optout
>     <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]
> <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.
Reply | Threaded
Open this post in threaded view
|

Re: self['@name']

horrido
I only want to access the mySound instance variable. The document says self['@mySound'] should do the trick. What can possibly go wrong???


On Monday, 21 November 2016 16:27:16 UTC-5, Herby wrote:
Richard Eng wrote:
> I have a separate JS file containing special routines I need: <script
> type="text/javascript" src="js/index.js"></script>

Well, then you do something wrong. How do you want to use 'self' outside
of the method?

>
>
> On Monday, 21 November 2016 15:03:51 UTC-5, Herby wrote:
>
>     Richard Eng wrote:
>      > I have an app with the following class:
>      >
>      > ||
>      > Objectsubclass:#Stressrelief
>      >  instanceVariableNames:'mySound currentTrack tracks mute cursor
>     images
>      > scheduled'
>      > package:'Stressrelief'
>      >
>      > I'm trying to access mySound from within JavaScript. Just to verify
>      > access, I pop up an alert:
>      >
>      > ||
>      > alert('mySound is '+self['@mySound']);
>
>     Well, this seems to be ok. Not to mentioned the error message
>     "mySound is undefined" refers to 'mySound'. not '@mySound'. Is it
>     the error message regarding that alert? Is that alert in the JS type
>     method (there is no online JS inside ST any more, for maybe three
>     years - inline JS only work in dedicated JS method.
>
>     Or is it that you have:
>
>     <inlineJS: ' alert('mySound is '+self['@mySound']);'>
>
>     In which case the apostrophe ends the string, thus it does not fit
>     into parse rule for new inlineJS, so it represents it as legacy JS
>     statement of:
>
>        inlineJS: 'alert'; // inlineJS in JS label
>        mySound; // here it should have blow
>     n with 'ReferenceError: mySound is undefined'
>        is;
>     '+ self';
>        @mySound; // well, this is really strange in JS and would blow
>     but did not get there
>     ']);';
>
>     Seems likely. The inlineJS: '....' needs '....' to be proper
>     Smalltalk string and nothing else should be present there. So either
>     using two apostrophes to escape it or use quote.
>
>      >
>      > Everywhere in my code, it tells me that "mySound is undefined". What
>      > have I missed from this document, "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=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw&#39;;return true;">https://github.com/amber-smalltalk/amber/wiki/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=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Famber-smalltalk%2Famber%2Fwiki%2FFrom-smalltalk-to-javascript-and-back\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFEoAvzKjJ20Ozb5129ypzW2j5ZSw&#39;;return true;">https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>>"?
>
>      >
>      > --
>      > 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:>
>      > <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="hqoMpykDBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+unsubscribe@... <javascript:>>.
>      > For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout
>     <<a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="hqoMpykDBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+...@googlegroups.com
> <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="hqoMpykDBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+unsubscribe@...>.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;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: self['@name']

Herby Vojčík
Richard Eng wrote:
> I only want to access the *mySound* instance variable. The document says
> self['@mySound'] should do the trick. /What can possibly go wrong???/

Nothing. If you use it in method. How do you want 'self' to be defined
otherwise?

>
>
> On Monday, 21 November 2016 16:27:16 UTC-5, Herby wrote:
>
>     Richard Eng wrote:
>      > I have a separate JS file containing special routines I need:
>     <script
>      > type="text/javascript" src="js/index.js"></script>

And this does not seem to be a method.

OTOH, if the error message is really 'mySound is undefined', then it
must occur somewhere else, not in self['@mySound'].

Find out where it fails. In compiled JS. And reverse engineer yourself
into the cause. From what you described, you are doing things in very
strange way (with the <script>). There is no 'self' at all there.

Herby

--
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: self['@name']

Herby Vojčík
In reply to this post by horrido
Richard Eng wrote:

> I have an app with the following class:
>
> ||
> Objectsubclass:#Stressrelief
>   instanceVariableNames:'mySound currentTrack tracks mute cursor images
> scheduled'
> package:'Stressrelief'
>
> I'm trying to access mySound from within JavaScript. Just to verify
> access, I pop up an alert:
>
> ||
> alert('mySound is '+self['@mySound']);

BTW why not just

   Platform alert: 'mySound is ', mySound asString.

inside Smalltalk itself?

>
> Everywhere in my code, it tells me that "mySound is undefined". What
> have I missed from this document, "From smalltalk to javascript and back
> <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>"?
>
> --
> 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.
Reply | Threaded
Open this post in threaded view
|

Re: self['@name']

Herby Vojčík
Herby Vojčík wrote:

> Richard Eng wrote:
>> I have an app with the following class:
>>
>> ||
>> Objectsubclass:#Stressrelief
>> instanceVariableNames:'mySound currentTrack tracks mute cursor images
>> scheduled'
>> package:'Stressrelief'
>>
>> I'm trying to access mySound from within JavaScript. Just to verify
>> access, I pop up an alert:
>>
>> ||
>> alert('mySound is '+self['@mySound']);
>
> BTW why not just
>
> Platform alert: 'mySound is ', mySound asString.

Oh, sorry, it's `Terminal alert:`, not `Platform alert:`. Those API
shifted a bit in latest versions and old ones were deprecated. Terminal
is old enough though (added in 0.14.14) so you should have it there.

>
> inside Smalltalk itself?
>
>>
>> Everywhere in my code, it tells me that "mySound is undefined". What
>> have I missed from this document, "From smalltalk to javascript and back
>> <https://github.com/amber-smalltalk/amber/wiki/From-smalltalk-to-javascript-and-back>"?
>>
>>
>> --
>> 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.
Reply | Threaded
Open this post in threaded view
|

Re: self['@name']

horrido
In reply to this post by Herby Vojčík
Okay, that's my problem. I'm trying to access mySound not from a method. So there is no way to access it from outside a method?

I thought I might try calling a Smalltalk method (doMute, which accesses mySound) from a JS function:

function myFunc() {
   
require("amber/helpers").globals.Stressrelief._doMute();
}

But this doesn't appear to work.


On Monday, 21 November 2016 16:41:12 UTC-5, Herby wrote:
Richard Eng wrote:
> I only want to access the *mySound* instance variable. The document says
> self['@mySound'] should do the trick. /What can possibly go wrong???/

Nothing. If you use it in method. How do you want 'self' to be defined
otherwise?

>
>
> On Monday, 21 November 2016 16:27:16 UTC-5, Herby wrote:
>
>     Richard Eng wrote:
>      > I have a separate JS file containing special routines I need:
>     <script
>      > type="text/javascript" src="js/index.js"></script>

And this does not seem to be a method.

OTOH, if the error message is really 'mySound is undefined', then it
must occur somewhere else, not in self['@mySound'].

Find out where it fails. In compiled JS. And reverse engineer yourself
into the cause. From what you described, you are doing things in very
strange way (with the <script>). There is no 'self' at all there.

Herby

--
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: self['@name']

Herby Vojčík
Richard Eng wrote:
> Okay, that's my problem. I'm trying to access mySound not from a method.
> So there is no way to access it from outside a method?

Well, whoever wrote that JS->ST->JS text just wrote "you use
self['@name']" and the conclusions:

   1. It uses self - so it is what I would use inside the method where
self is known.
   2. It means that Amber objects hold their 'name' ivar in JS property
'@name', so if I have an instance in variable foo, I can do foo['@name'].

are left to the reader.

So, yes, you can. Using conclusion 2.

> I thought I might try calling a Smalltalk method (*doMute*, which
> accesses mySound) from a JS function:
>
> ||
> functionmyFunc(){
> require("amber/helpers").globals.Stressrelief._doMute();
> }

You surely did not presume that when you get the class Stressrelief via
`require("amber/helpers").globals.Stressrelief` and append `._doMute()`
you are calling anything else than the class method doMute of class
Stressrelief.

> But this doesn't appear to work.

And I am sure it works. Maybe you do not have such class method in the
first place (or you do not want to call a class method in fact).

Herby

> On Monday, 21 November 2016 16:41:12 UTC-5, Herby wrote:
>
>     Richard Eng wrote:
>      > I only want to access the *mySound* instance variable. The
>     document says
>      > self['@mySound'] should do the trick. /What can possibly go
>     wrong???/
>
>     Nothing. If you use it in method. How do you want 'self' to be defined
>     otherwise?
>
>      >
>      >
>      > On Monday, 21 November 2016 16:27:16 UTC-5, Herby wrote:
>      >
>      >     Richard Eng wrote:
>      > > I have a separate JS file containing special routines I need:
>      > <script
>      > > type="text/javascript" src="js/index.js"></script>
>
>     And this does not seem to be a method.
>
>     OTOH, if the error message is really 'mySound is undefined', then it
>     must occur somewhere else, not in self['@mySound'].
>
>     Find out where it fails. In compiled JS. And reverse engineer yourself
>     into the cause. From what you described, you are doing things in very
>     strange way (with the <script>). There is no 'self' at all there.
>
>     Herby
>
> --
> 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.
Reply | Threaded
Open this post in threaded view
|

Re: self['@name']

horrido
Oh, so it has to be a class method! I didn't know that. It's not obvious.

So I cannot call an instance method?


On Tuesday, 22 November 2016 11:12:06 UTC-5, Herby wrote:
Richard Eng wrote:
> Okay, that's my problem. I'm trying to access mySound not from a method.
> So there is no way to access it from outside a method?

Well, whoever wrote that JS->ST->JS text just wrote "you use
self['@name']" and the conclusions:

   1. It uses self - so it is what I would use inside the method where
self is known.
   2. It means that Amber objects hold their 'name' ivar in JS property
'@name', so if I have an instance in variable foo, I can do foo['@name'].

are left to the reader.

So, yes, you can. Using conclusion 2.

> I thought I might try calling a Smalltalk method (*doMute*, which
> accesses mySound) from a JS function:
>
> ||
> functionmyFunc(){
> require("amber/helpers").globals.Stressrelief._doMute();
> }

You surely did not presume that when you get the class Stressrelief via
`require("amber/helpers").globals.Stressrelief` and append `._doMute()`
you are calling anything else than the class method doMute of class
Stressrelief.

> But this doesn't appear to work.

And I am sure it works. Maybe you do not have such class method in the
first place (or you do not want to call a class method in fact).

Herby

> On Monday, 21 November 2016 16:41:12 UTC-5, Herby wrote:
>
>     Richard Eng wrote:
>      > I only want to access the *mySound* instance variable. The
>     document says
>      > self['@mySound'] should do the trick. /What can possibly go
>     wrong???/
>
>     Nothing. If you use it in method. How do you want 'self' to be defined
>     otherwise?
>
>      >
>      >
>      > On Monday, 21 November 2016 16:27:16 UTC-5, Herby wrote:
>      >
>      >     Richard Eng wrote:
>      > > I have a separate JS file containing special routines I need:
>      > <script
>      > > type="text/javascript" src="js/index.js"></script>
>
>     And this does not seem to be a method.
>
>     OTOH, if the error message is really 'mySound is undefined', then it
>     must occur somewhere else, not in self['@mySound'].
>
>     Find out where it fails. In compiled JS. And reverse engineer yourself
>     into the cause. From what you described, you are doing things in very
>     strange way (with the <script>). There is no 'self' at all there.
>
>     Herby
>
> --
> 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="cvsHaItABAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+...@googlegroups.com
> <mailto:<a href="javascript:" target="_blank" gdf-obfuscated-mailto="cvsHaItABAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">amber-lang+unsubscribe@...>.
> For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;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: self['@name']

Herby Vojčík
Richard Eng wrote:
> Oh, so it has to be a class method! I didn't know that. It's not obvious.
>
> So I cannot call an instance method?

[PERSONAL] What's wrong with you? Stop with that cargo cult programming
approach. Of course you can. You can call methods / inspect ivars for
any object. I'll paste it here again with some emphases:

   You surely did not presume that when you >>>get the class
Stressrelief<<< via
   `require("amber/helpers").globals.Stressrelief` >>>and append
`._doMute()`<<<
   you are calling anything else than the class >>>method doMute of class
   Stressrelief<<<.

--
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: self['@name']

Herby Vojčík
Great. I wanted to send personal but it went to ML. :-/

Herby Vojčík wrote:

> Richard Eng wrote:
>> Oh, so it has to be a class method! I didn't know that. It's not obvious.
>>
>> So I cannot call an instance method?
>
> [PERSONAL] What's wrong with you? Stop with that cargo cult programming
> approach. Of course you can. You can call methods / inspect ivars for
> any object. I'll paste it here again with some emphases:
>
> You surely did not presume that when you >>>get the class
> Stressrelief<<< via
> `require("amber/helpers").globals.Stressrelief` >>>and append
> `._doMute()`<<<
> you are calling anything else than the class >>>method doMute of class
> Stressrelief<<<.
>

--
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: self['@name']

Dave Mason-3
In reply to this post by horrido
If you have an object foo that was created (by Stressrelief new from within Amber (or PharoJS) code or Stressrelief._new() from Javascript) then you can access the field as foo['@mysound'] in Amber (with PharoJS it would simply be foo.mysound ).

.,./Dave

../Dave

On Tue, Nov 22, 2016 at 12:40 PM, Richard Eng <[hidden email]> wrote:
Oh, so it has to be a class method! I didn't know that. It's not obvious.

So I cannot call an instance method?


On Tuesday, 22 November 2016 11:12:06 UTC-5, Herby wrote:
Richard Eng wrote:
> Okay, that's my problem. I'm trying to access mySound not from a method.
> So there is no way to access it from outside a method?

Well, whoever wrote that JS->ST->JS text just wrote "you use
self['@name']" and the conclusions:

   1. It uses self - so it is what I would use inside the method where
self is known.
   2. It means that Amber objects hold their 'name' ivar in JS property
'@name', so if I have an instance in variable foo, I can do foo['@name'].

are left to the reader.

So, yes, you can. Using conclusion 2.

> I thought I might try calling a Smalltalk method (*doMute*, which
> accesses mySound) from a JS function:
>
> ||
> functionmyFunc(){
> require("amber/helpers").globals.Stressrelief._doMute();
> }

You surely did not presume that when you get the class Stressrelief via
`require("amber/helpers").globals.Stressrelief` and append `._doMute()`
you are calling anything else than the class method doMute of class
Stressrelief.

> But this doesn't appear to work.

And I am sure it works. Maybe you do not have such class method in the
first place (or you do not want to call a class method in fact).

Herby

> On Monday, 21 November 2016 16:41:12 UTC-5, Herby wrote:
>
>     Richard Eng wrote:
>      > I only want to access the *mySound* instance variable. The
>     document says
>      > self['@mySound'] should do the trick. /What can possibly go
>     wrong???/
>
>     Nothing. If you use it in method. How do you want 'self' to be defined
>     otherwise?
>
>      >
>      >
>      > On Monday, 21 November 2016 16:27:16 UTC-5, Herby wrote:
>      >
>      >     Richard Eng wrote:
>      > > I have a separate JS file containing special routines I need:
>      > <script
>      > > type="text/javascript" src="js/index.js"></script>
>
>     And this does not seem to be a method.
>
>     OTOH, if the error message is really 'mySound is undefined', then it
>     must occur somewhere else, not in self['@mySound'].
>
>     Find out where it fails. In compiled JS. And reverse engineer yourself
>     into the cause. From what you described, you are doing things in very
>     strange way (with the <script>). There is no 'self' at all there.
>
>     Herby
>
> --
> 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
> <mailto:amber-lang+unsubscribe@googlegroups.com>.
> 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.

--
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.