Unknown variables 2

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

Unknown variables 2

Herby Vojčík
Hello,

the `(smalltalk.Foo || Foo)` (and unknown variable as invitation to use
global variables seamlessly; which is a bit of an antipattern IMHO) is
still making me nervous. So I came with the different proposal:

Let <...> have two uses:
1. Inline JS statement (as its node name suggests). Every <...> will be
parsed as this, except:
2. Global variable access. If inside <...> is an identifier and nothing
more, it should be parsed as ExternalGlobalVariableNode (a new node).

So `console log: 'Hello, world'` gets only just a little more
complicated (and more explicit): `<console> log: 'Hello, world!'`. More
over, any `Capitalized` alone would be unambiguously interpret as
smalltalk.Capitalized and to use outer variable beginning with capital
letter, one should use eg. `<Math> max: 2 and: 3 and: 4`.

Is this more acceptable?

Herby
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variables 2

Nicolas Petton
Herby Vojčík <[hidden email]> writes:

Hello Herby,

This indeed sounds better to me :)
I still have a few remarks:

- I don't like the idea of having the same syntax for 2 different
semantics, even more because it's not 'normal' Smalltalk syntax

- instead of having a special syntax, what about adding some kind of
simple namespace for javascript object access? Something like the
following:

JavaScript console log: 'hello'

It looks a lot more Smalltalkish, and instead of adding new semantic, we
can add a new pseudo variable.

Cheers,
Nico

> Hello,
>
> the `(smalltalk.Foo || Foo)` (and unknown variable as invitation to
> use global variables seamlessly; which is a bit of an antipattern
> IMHO) is still making me nervous. So I came with the different
> proposal:
>
> Let <...> have two uses:
> 1. Inline JS statement (as its node name suggests). Every <...> will
> be parsed as this, except:
> 2. Global variable access. If inside <...> is an identifier and
> nothing more, it should be parsed as ExternalGlobalVariableNode (a new
> node).
>
> So `console log: 'Hello, world'` gets only just a little more
> complicated (and more explicit): `<console> log: 'Hello,
> world!'`. More over, any `Capitalized` alone would be unambiguously
> interpret as smalltalk.Capitalized and to use outer variable beginning
> with capital letter, one should use eg. `<Math> max: 2 and: 3 and: 4`.
>
> Is this more acceptable?
>
> Herby
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variables 2

Amber Milan Eskridge
JavaScript console log: 'hello'
+1

On Sun, May 6, 2012 at 2:31 PM, <[hidden email]> wrote:
Herby Vojčík <[hidden email]> writes:

Hello Herby,

This indeed sounds better to me :)
I still have a few remarks:

- I don't like the idea of having the same syntax for 2 different
semantics, even more because it's not 'normal' Smalltalk syntax

- instead of having a special syntax, what about adding some kind of
simple namespace for javascript object access? Something like the
following:

JavaScript console log: 'hello'

It looks a lot more Smalltalkish, and instead of adding new semantic, we
can add a new pseudo variable.

Cheers,
Nico

> Hello,
>
> the `(smalltalk.Foo || Foo)` (and unknown variable as invitation to
> use global variables seamlessly; which is a bit of an antipattern
> IMHO) is still making me nervous. So I came with the different
> proposal:
>
> Let <...> have two uses:
> 1. Inline JS statement (as its node name suggests). Every <...> will
> be parsed as this, except:
> 2. Global variable access. If inside <...> is an identifier and
> nothing more, it should be parsed as ExternalGlobalVariableNode (a new
> node).
>
> So `console log: 'Hello, world'` gets only just a little more
> complicated (and more explicit): `<console> log: 'Hello,
> world!'`. More over, any `Capitalized` alone would be unambiguously
> interpret as smalltalk.Capitalized and to use outer variable beginning
> with capital letter, one should use eg. `<Math> max: 2 and: 3 and: 4`.
>
> Is this more acceptable?
>
> Herby

Reply | Threaded
Open this post in threaded view
|

Re: Unknown variables 2

Herby Vojčík
In reply to this post by Nicolas Petton
[hidden email] wrote:
> Herby Vojčík<[hidden email]>  writes:
>
> Hello Herby,
>
> This indeed sounds better to me :)
> I still have a few remarks:
>
> - I don't like the idea of having the same syntax for 2 different
> semantics, even more because it's not 'normal' Smalltalk syntax

Well, if <> would only be standalone JS statement, I'd like it.

> - instead of having a special syntax, what about adding some kind of
> simple namespace for javascript object access? Something like the
> following:
>
> JavaScript console log: 'hello'

Javascript isn't written in two words :-( You do to JS what others do to
Smalltalk by writing SmallTalk (this one is scarier, of course).

> It looks a lot more Smalltalkish, and instead of adding new semantic, we
> can add a new pseudo variable.

I would call it Host. What if Amber would run on Dart / Clojure /
godknowswhatbrowserlanguage in the future?

> Cheers,
> Nico
>
>> Hello,
>>
>> the `(smalltalk.Foo || Foo)` (and unknown variable as invitation to
>> use global variables seamlessly; which is a bit of an antipattern
>> IMHO) is still making me nervous. So I came with the different
>> proposal:
>>
>> Let<...>  have two uses:
>> 1. Inline JS statement (as its node name suggests). Every<...>  will
>> be parsed as this, except:
>> 2. Global variable access. If inside<...>  is an identifier and
>> nothing more, it should be parsed as ExternalGlobalVariableNode (a new
>> node).
>>
>> So `console log: 'Hello, world'` gets only just a little more
>> complicated (and more explicit): `<console>  log: 'Hello,
>> world!'`. More over, any `Capitalized` alone would be unambiguously
>> interpret as smalltalk.Capitalized and to use outer variable beginning
>> with capital letter, one should use eg. `<Math>  max: 2 and: 3 and: 4`.
>>
>> Is this more acceptable?
>>
>> Herby
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variables 2

Nicolas Petton
Herby Vojčík <[hidden email]> writes:

> [hidden email] wrote:
>> Herby Vojčík<[hidden email]>  writes:
>>
>> Hello Herby,
>>
>> This indeed sounds better to me :)
>> I still have a few remarks:
>>
>> - I don't like the idea of having the same syntax for 2 different
>> semantics, even more because it's not 'normal' Smalltalk syntax
>
> Well, if <> would only be standalone JS statement, I'd like it.
>
>> - instead of having a special syntax, what about adding some kind of
>> simple namespace for javascript object access? Something like the
>> following:
>>
>> JavaScript console log: 'hello'
>
> Javascript isn't written in two words :-( You do to JS what others do
> to Smalltalk by writing SmallTalk (this one is scarier, of course).

Oh, really? I always thought it was JavaScript, not
Javascript. Wikipedia and the MDN seem to agree with me :)
https://developer.mozilla.org/en/JavaScript

>
>> It looks a lot more Smalltalkish, and instead of adding new semantic, we
>> can add a new pseudo variable.
>
> I would call it Host. What if Amber would run on Dart / Clojure /
> godknowswhatbrowserlanguage in the future?

Then we'll change it :) Amber is tightly coupled to Java{S,s}cript
anyway.

Cheers,
Nico



>> Cheers,
>> Nico
>>
>>> Hello,
>>>
>>> the `(smalltalk.Foo || Foo)` (and unknown variable as invitation to
>>> use global variables seamlessly; which is a bit of an antipattern
>>> IMHO) is still making me nervous. So I came with the different
>>> proposal:
>>>
>>> Let<...>  have two uses:
>>> 1. Inline JS statement (as its node name suggests). Every<...>  will
>>> be parsed as this, except:
>>> 2. Global variable access. If inside<...>  is an identifier and
>>> nothing more, it should be parsed as ExternalGlobalVariableNode (a new
>>> node).
>>>
>>> So `console log: 'Hello, world'` gets only just a little more
>>> complicated (and more explicit): `<console>  log: 'Hello,
>>> world!'`. More over, any `Capitalized` alone would be unambiguously
>>> interpret as smalltalk.Capitalized and to use outer variable beginning
>>> with capital letter, one should use eg. `<Math>  max: 2 and: 3 and: 4`.
>>>
>>> Is this more acceptable?
>>>
>>> Herby
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variables 2

Herby Vojčík


[hidden email] wrote:

> Herby Vojčík<[hidden email]>  writes:
>
>> [hidden email] wrote:
>>> Herby Vojčík<[hidden email]>   writes:
>>>
>>> Hello Herby,
>>>
>>> This indeed sounds better to me :)
>>> I still have a few remarks:
>>>
>>> - I don't like the idea of having the same syntax for 2 different
>>> semantics, even more because it's not 'normal' Smalltalk syntax
>> Well, if<>  would only be standalone JS statement, I'd like it.
>>
>>> - instead of having a special syntax, what about adding some kind of
>>> simple namespace for javascript object access? Something like the
>>> following:
>>>
>>> JavaScript console log: 'hello'
>> Javascript isn't written in two words :-( You do to JS what others do
>> to Smalltalk by writing SmallTalk (this one is scarier, of course).
>
> Oh, really? I always thought it was JavaScript, not
> Javascript. Wikipedia and the MDN seem to agree with me :)
> https://developer.mozilla.org/en/JavaScript
If MDN says that... ok. Then I was mistaken.

Reply | Threaded
Open this post in threaded view
|

Re: Unknown variables 2

Herby Vojčík
In reply to this post by Nicolas Petton
[hidden email] wrote:

> Herby Vojčík<[hidden email]>  writes:
>
> Hello Herby,
>
> This indeed sounds better to me :)
> I still have a few remarks:
>
> - I don't like the idea of having the same syntax for 2 different
> semantics, even more because it's not 'normal' Smalltalk syntax
>
> - instead of having a special syntax, what about adding some kind of
> simple namespace for javascript object access? Something like the
> following:
>
> JavaScript console log: 'hello'

This has problem that it does not solve capitalized globals (unless I am
mistaken, message can't start with capital letter).

The possible workarounds I see are (for Math example):

'Math' jsGlobal
JavaScript @ 'Math'

The latter must be parenthesized in some situation anyway, JavaScript
at: 'Math' is quirky because it must be parenthesized anyway.


And one more important thing: you cannot assign to 'JavaScript console'.
Only thing you can do is "JavaScript at: 'console' put: ...".

So either at:put: (hardly inlineable) or some sort of real namespace
(JavaScript.console, Javascript.Math without whitespace after dot; but
Pharo does not have namespaces, does it?) or I would revitalize my
proposal <identifier> for any host-provided identifier.

> It looks a lot more Smalltalkish, and instead of adding new semantic, we
> can add a new pseudo variable.
>
> Cheers,
> Nico
>
>> Hello,
>>
>> the `(smalltalk.Foo || Foo)` (and unknown variable as invitation to
>> use global variables seamlessly; which is a bit of an antipattern
>> IMHO) is still making me nervous. So I came with the different
>> proposal:
>>
>> Let<...>  have two uses:
>> 1. Inline JS statement (as its node name suggests). Every<...>  will
>> be parsed as this, except:
>> 2. Global variable access. If inside<...>  is an identifier and
>> nothing more, it should be parsed as ExternalGlobalVariableNode (a new
>> node).
>>
>> So `console log: 'Hello, world'` gets only just a little more
>> complicated (and more explicit): `<console>  log: 'Hello,
>> world!'`. More over, any `Capitalized` alone would be unambiguously
>> interpret as smalltalk.Capitalized and to use outer variable beginning
>> with capital letter, one should use eg. `<Math>  max: 2 and: 3 and: 4`.
>>
>> Is this more acceptable?
>>
>> Herby
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variables 2

Nicolas Petton
Herby Vojčík <[hidden email]> writes:

> This has problem that it does not solve capitalized globals (unless I
> am mistaken, message can't start with capital letter).

Yep, messages can start with a capital letter.

Nico
Reply | Threaded
Open this post in threaded view
|

Re: Unknown variables 2

Herby Vojčík


[hidden email] wrote:
> Herby Vojčík<[hidden email]>  writes:
>
>> This has problem that it does not solve capitalized globals (unless I
>> am mistaken, message can't start with capital letter).
>
> Yep, messages can start with a capital letter.

Ah, ok. And writing is also ok via JavaScript Foo: bar, I have somehow
forgot, sorry. Ok, then.

I must ask Brendan Eich how is Javascript really called, to be sure :-)

> Nico

Herby