[squeak-dev] Metacello

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

Re: [squeak-dev] Clamato

Dan Ingalls
> > That said, though, are you open to a possible collaboration to put a bit more attention on making it the best it can be without making it significantly more complicated.
>
>Absolutely.  I would be delighted to have more collaboration on this
>(and honored, Dan, to have yours) - though of course I also reserve
>the right to ignore any and all suggestions :)

Avi -

This looks better than I had thought, and about as good as I can imagine for this kind of adaptation.

I'll spend a bit of time on LK and see how it looks.  I understand your focus on the DOM, and we've talked about having a more DOM-oriented LK anyway.  It all looks like fun.

Thanks for taking the trouble (to do it first, then to explain these aspects).

        - Dan

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Jason Rogers-4
In reply to this post by Avi Bryant-2
A (hopefully) simple question. How would you implement #perform:with:
? JS can handle the reflection (either via eval(...) or function
pointers).

BTW: This looks great!

--
Jason Rogers

"I am crucified with Christ: nevertheless I live;
yet not I, but Christ liveth in me: and the life
which I now live in the flesh I live by the faith of
the Son of God, who loved me, and gave
himself for me."
    Galatians 2:20

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Avi Bryant-2
On Sat, Sep 5, 2009 at 8:07 AM, Jason Rogers<[hidden email]> wrote:
> A (hopefully) simple question. How would you implement #perform:with:
> ? JS can handle the reflection (either via eval(...) or function
> pointers).

Here's an implementation as a primitive:

- perform: aString with: anObject {
     return this[aString._mangleSelector()](anObject);
}.

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Robert Krahn-2
Hi, Avi -

I just tried to implement this method without using JavaScript. Here is what I have:

- perform: selector with: anObject

| method evalString |
@class withAncestors do: [:ea |
(ea methodAt: selector) ifNotNilDo: [:m | method := m]].
method ifNil: [self error: 'Method ' , selector , ' not found!'].
evalString := '(' , method asJavascript , ')(' , anObject , ')'.
evalString eval.

I expected this to work, however, String>>eval just returns the String. The same happens when I try to do '1+1'._eval() in a JS console. Do you know where the problem is?

Thanks,
Robert

Here's an implementation as a primitive:

- perform: aString with: anObject {
    return this[aString._mangleSelector()](anObject);
}.




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Alejandro F. Reimondo
In reply to this post by Avi Bryant-2
Hi Avi,
Clamato freezed my browser; I suppose it happens because
 it is Internet Explorer 8 and some settings can be inhibiting
 it to run as expected.
So, please consider that my questions come from a person
 that couldn´t see it running nor get information by himself. :-)

You claim that Clamato is a Smalltalk... for me, it implies
 that it is an object environment, e.g. it has support
 for at least this features:
- snapshot (can be primitive) that save the complete
  environment (or subset) capable to restart without
  loosing valuable state/information.
- become (&/or massive become) facility
- allInstances or an efficient way to iterate instances
  of a class (species or something equivalent) not known
  before evaluation time (e.g. can´t predict wich will be the
  class to change design).

Can you confirm that those features are implemented
 or that can be implemented efficiently?

thanks in advance and thank you for sharing
 the results of your work,
Ale.



----- Original Message -----
From: "Avi Bryant" <[hidden email]>
To: "The general-purpose Squeak developers list"
<[hidden email]>
Sent: Saturday, September 05, 2009 1:43 PM
Subject: Re: [squeak-dev] Clamato


> On Sat, Sep 5, 2009 at 8:07 AM, Jason Rogers<[hidden email]> wrote:
>> A (hopefully) simple question. How would you implement #perform:with:
>> ? JS can handle the reflection (either via eval(...) or function
>> pointers).
>
> Here's an implementation as a primitive:
>
> - perform: aString with: anObject {
>     return this[aString._mangleSelector()](anObject);
> }.
>
>



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Avi Bryant-2
On Sat, Sep 5, 2009 at 3:06 PM, Alejandro F.
Reimondo<[hidden email]> wrote:

> You claim that Clamato is a Smalltalk... for me, it implies
> that it is an object environment, e.g. it has support
> for at least this features:
> - snapshot (can be primitive) that save the complete
>  environment (or subset) capable to restart without
>  loosing valuable state/information.
> - become (&/or massive become) facility
> - allInstances or an efficient way to iterate instances
>  of a class (species or something equivalent) not known
>  before evaluation time (e.g. can´t predict wich will be the
>  class to change design).
>
> Can you confirm that those features are implemented
> or that can be implemented efficiently?

Clamato runs on top of a Javascript VM, and whether it has those
features or not depends entirely on whether the underlying Javascript
VM does.  For example, I believe that V8 can snapshot.  I don't
believe become: or allInstances are available currently.  If that
makes Clamato "not a Smalltalk", I'm fine with that - consider it a
language/environment inspired by Smalltalk, instead.

Avi

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Alejandro F. Reimondo
Hi Avi,
Thanks for your fast and direct response.
To discriminate between smalltalk and alternatives inspired
 in smalltalk is as valuable as to distinguish a
 smalltalker form a person inspired by smalltalk [*].
cheers,
Ale.
[*] e.g. to trace the extintion of the smalltalker species and
 how it vanishes by decomposition (in fragments returning
 to the/another future).



----- Original Message -----
From: "Avi Bryant" <[hidden email]>
To: "The general-purpose Squeak developers list"
<[hidden email]>
Sent: Saturday, September 05, 2009 7:53 PM
Subject: Re: [squeak-dev] Clamato


On Sat, Sep 5, 2009 at 3:06 PM, Alejandro F.
Reimondo<[hidden email]> wrote:

> You claim that Clamato is a Smalltalk... for me, it implies
> that it is an object environment, e.g. it has support
> for at least this features:
> - snapshot (can be primitive) that save the complete
> environment (or subset) capable to restart without
> loosing valuable state/information.
> - become (&/or massive become) facility
> - allInstances or an efficient way to iterate instances
> of a class (species or something equivalent) not known
> before evaluation time (e.g. can´t predict wich will be the
> class to change design).
>
> Can you confirm that those features are implemented
> or that can be implemented efficiently?

Clamato runs on top of a Javascript VM, and whether it has those
features or not depends entirely on whether the underlying Javascript
VM does.  For example, I believe that V8 can snapshot.  I don't
believe become: or allInstances are available currently.  If that
makes Clamato "not a Smalltalk", I'm fine with that - consider it a
language/environment inspired by Smalltalk, instead.

Avi




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Jason Rogers-4
In reply to this post by Avi Bryant-2
Have you tried that? It doesn't seem to work for me. Tried saving it
on Object, but it's not invoked as far as I can tell.

I am trying a different refactoring, like so:

- renderOn: html
        ...
        self renderButtonFor: '+' on: html.
        self renderButtonFor: '-' on: html.
        ...

- renderButtonFor: operation on: html
        html button
                with: operation;
                onClick: [@counter := @counter perform: operation with: 1. self reload].

On Sat, Sep 5, 2009 at 12:43 PM, Avi Bryant<[hidden email]> wrote:

> On Sat, Sep 5, 2009 at 8:07 AM, Jason Rogers<[hidden email]> wrote:
>> A (hopefully) simple question. How would you implement #perform:with:
>> ? JS can handle the reflection (either via eval(...) or function
>> pointers).
>
> Here's an implementation as a primitive:
>
> - perform: aString with: anObject {
>     return this[aString._mangleSelector()](anObject);
> }.
>
>



--
Jason Rogers

"I am crucified with Christ: nevertheless I live;
yet not I, but Christ liveth in me: and the life
which I now live in the flesh I live by the faith of
the Son of God, who loved me, and gave
himself for me."
    Galatians 2:20

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Avi Bryant-2
On Sat, Sep 5, 2009 at 8:12 PM, Jason Rogers<[hidden email]> wrote:
> Have you tried that? It doesn't seem to work for me. Tried saving it
> on Object, but it's not invoked as far as I can tell.

So, I think the problem you're running into is nothing to do with the
implementation of #perform:with:, but rather with the hackish way in
which Javascript-native types like Number and String "inherit" from
clamato.Object, which is to say that they don't - the Object methods
just get copied into them on load (this avoids adding any properties
to the real Javascript root Object, which is important for
compatibility with other JS code).

If, after adding perform:with: to Object, you run clamato._setup() in
the JS console, your refactoring should start working.

Avi

>
> I am trying a different refactoring, like so:
>
> - renderOn: html
>        ...
>        self renderButtonFor: '+' on: html.
>        self renderButtonFor: '-' on: html.
>        ...
>
> - renderButtonFor: operation on: html
>        html button
>                with: operation;
>                onClick: [@counter := @counter perform: operation with: 1. self reload].
>
> On Sat, Sep 5, 2009 at 12:43 PM, Avi Bryant<[hidden email]> wrote:
>> On Sat, Sep 5, 2009 at 8:07 AM, Jason Rogers<[hidden email]> wrote:
>>> A (hopefully) simple question. How would you implement #perform:with:
>>> ? JS can handle the reflection (either via eval(...) or function
>>> pointers).
>>
>> Here's an implementation as a primitive:
>>
>> - perform: aString with: anObject {
>>     return this[aString._mangleSelector()](anObject);
>> }.
>>
>>
>
>
>
> --
> Jason Rogers
>
> "I am crucified with Christ: nevertheless I live;
> yet not I, but Christ liveth in me: and the life
> which I now live in the flesh I live by the faith of
> the Son of God, who loved me, and gave
> himself for me."
>    Galatians 2:20
>
>

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Avi Bryant-2
In reply to this post by Robert Krahn-2
On Sat, Sep 5, 2009 at 10:57 AM, Robert
Krahn<[hidden email]> wrote:

> I expected this to work, however, String>>eval just returns the String. The
> same happens when I try to do '1+1'._eval() in a JS console. Do you know
> where the problem is?

Javascript's eval has confusing semantics - try using globalEval
instead.  Though, even with that I'm not sure your code would work -
what do you expect "method asJavascript" to return?  I don't think it
will be anything useful.

Avi

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Robert Krahn-2
Seems that the semantics of globalEval are also a bit confusing. The code passed to it is evaluated but the value of the last expression isn't returned.

#asJavascript returns the method/function as a String but I forgot that self is bound to this which will be window in the function.

The code below works for me in Safari, but yes it's really creepy :-)

- perform: selector with: anObject | method evalString | @class withAncestors do: [:ea | (ea methodAt: selector) ifNotNilDo: [:m | method := m]]. method ifNil: [self error: 'Method ' , selector , ' not found!']. performSelf := self. evalString := 'performResult = (' , method asJavascript , ').call(performSelf,' , anObject , ')'. evalString globalEval. performResult.

Robert

On Sep 6, 2009, at 9:48 AM, Avi Bryant wrote:

On Sat, Sep 5, 2009 at 10:57 AM, Robert
Krahn<[hidden email]> wrote:

I expected this to work, however, String>>eval just returns the String. The
same happens when I try to do '1+1'._eval() in a JS console. Do you know
where the problem is?

Javascript's eval has confusing semantics - try using globalEval
instead.  Though, even with that I'm not sure your code would work -
what do you expect "method asJavascript" to return?  I don't think it
will be anything useful.

Avi




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Randal L. Schwartz
In reply to this post by Alejandro F. Reimondo
>>>>> "Alejandro" == Alejandro F Reimondo <[hidden email]> writes:

Alejandro> You claim that Clamato is a Smalltalk... for me, it implies
Alejandro> that it is an object environment, e.g. it has support
Alejandro> for at least this features:
Alejandro> - snapshot (can be primitive) that save the complete
Alejandro>  environment (or subset) capable to restart without
Alejandro>  loosing valuable state/information.
Alejandro> - become (&/or massive become) facility
Alejandro> - allInstances or an efficient way to iterate instances
Alejandro>  of a class (species or something equivalent) not known
Alejandro>  before evaluation time (e.g. can´t predict wich will be the
Alejandro>  class to change design).

I'd have to say that those are specific things that *you* in particular demand
from what you think Smalltalk is, and not things that are intrinsic in
Smalltalk.

For example, by those rules, GNU Smalltalk would not be "Smalltalk".  And I
think you'd find thousands of people disagreeing with you.

Please consider this as you evaluate Clamato for what it is.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Alejandro F. Reimondo
Dear Randal,
Thanks for your email.
When I desided to give a chance to Smalltalk
 I started a path that let me exploit the diferences in pov
 with thouthands of people (never returned to Pascal,
 that governed the "way of thinking about software"
 at that time).
Now it is too late for me to feel confortable following
 "the" crowd.
The reason why I wrote the email was to say that there
 are other ways to consider smalltalk.
How we consider Smalltalk, dependes on what we
 can get from it, and how much we have to loose
 when we conform the commons.
all the best,
Ale.

----- Original Message -----
From: "Randal L. Schwartz" <[hidden email]>
To: "Alejandro F. Reimondo" <[hidden email]>
Cc: "The general-purpose Squeak developers list"
<[hidden email]>
Sent: Sunday, September 06, 2009 11:43 AM
Subject: Re: [squeak-dev] Clamato


>>>>> "Alejandro" == Alejandro F Reimondo <[hidden email]>
>>>>> writes:

Alejandro> You claim that Clamato is a Smalltalk... for me, it implies
Alejandro> that it is an object environment, e.g. it has support
Alejandro> for at least this features:
Alejandro> - snapshot (can be primitive) that save the complete
Alejandro>  environment (or subset) capable to restart without
Alejandro>  loosing valuable state/information.
Alejandro> - become (&/or massive become) facility
Alejandro> - allInstances or an efficient way to iterate instances
Alejandro>  of a class (species or something equivalent) not known
Alejandro>  before evaluation time (e.g. can´t predict wich will be the
Alejandro>  class to change design).

I'd have to say that those are specific things that *you* in particular
demand
from what you think Smalltalk is, and not things that are intrinsic in
Smalltalk.

For example, by those rules, GNU Smalltalk would not be "Smalltalk".  And I
think you'd find thousands of people disagreeing with you.

Please consider this as you evaluate Clamato for what it is.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Dan Ingalls
In reply to this post by Bert Freudenberg
>You claim that Clamato is a Smalltalk... for me, it implies
>that it is an object environment, e.g. it has support
>for at least this features:
>- snapshot (can be primitive) that save the complete
> environment (or subset) capable to restart without
> loosing valuable state/information.
>- become (&/or massive become) facility
>- allInstances or an efficient way to iterate instances
> of a class (species or something equivalent) not known
> before evaluation time (e.g. can´t predict wich will be the
> class to change design).

Hi Alejandro and all -

I think these concerns have already been answered by others, but I also had a few things to add.

Smalltalk (bless its soul) is both a nice programming language, and a great meta programming environment.  While I feel one should always have both, and I can't believe that everything done since 1970 or even 1980 isn't at least as good in both dimensions, we live in an imperfect world.

Along with its imperfections, this world nonetheless provides us with various opportunities, some that are elegant, and some merely pragmatic.  The ubiquity of JavaScript and the recent escalation of its performance are two significant opportunities that we would probably all put in the latter category.  Nonetheless they are opportunities.  That's what made me interested in the Lively Kernel idea (a "Smalltalk only at the level of Morphic with an IDE), and I think it's what got Avi thinking about Clamato.

I agree absolutely with the importance of the deep and elegant aspects of Smalltalk (natch), but I think it's also worth pondering and perhaps even embracing the possibilities afforded by the JS engines of today.

For example I lamented for a while the inadequate hooks to JS VMs so that we could not do tracing, execution counts or time profiles.  But (as you may know) it turned out that just one page of code allowed us to do all these on any JavaScript without any special VM hooks.  A little reflection (and JS does have some) goes a long way.

So I am sure we will find ways to recreate many of these deeper capabilities in JavaScript and, hey, if the engines get much faster, we can just run the Squeak Interpreter in JS (just kidding).

Now to my earlier comment about LK/Clamato synergy, and in response to the snapshot reference, one of the coolest things we did in the Lively Kernel, mostly the work of Robert Krahn, was to build a client-side wiki using WebDAV protocol to store web pages.  We also added a changeSet that was held onto by the World, so that it got saved with the page.  Then when the page gets loaded, it will re-eval everything in the changeSet, and -- voila -- all the old windows and objects in the world are restored, and so are all the changes prior to the save.  This is very much of the convenience of snapshots, including the ability to save from a Mac in Safari, and resume in, eg, Firefox on a PC.  Moreover the way Robert did it, you can also easily revert to any prior version which can be a great time saver.

I told my sad story of not having done the St syntax hack for April Fools, but here Avi has done all the work and has a real artifact to show for it.  It doesn't mean anyone should drop Smalltalk, but it does mean that there's now a real chance of recreating many of the powerful tools we love, and even much of the language we love, in an environment that is live on every desktop and half the phones in the world.

        - Dan

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Bert Freudenberg
In reply to this post by Dan Ingalls
On 04.09.2009, at 20:53, Dan Ingalls wrote:

> Hi, Avi
>> I tried to leave out the cascade syntax, but found it was too useful
>> and had to put it back.
>
> I love it!  I've always felt a bit sheepish about cascades, but I  
> put them in because it was a pattern that we found useful in St72  
> and I wanted to preserve as much as possible of that convenience.

Me too! And how well the ";" works with "." to separate statement is  
amazing. Others are imitating the cascade style by "chaining" but it  
looks weird and is limited at the same time; see e.g. this message I  
just got on a Python list:

Begin forwarded message:

> it would be awesome to set up chaining so we could do something like
>
> layer['timer'].save().clear().
>        fillStyle('#fff').
>        fillRect(10, startTimerY, endTimerX, offsetTimerY).
>        restore();

- Bert -



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Clamato

Sophie424
Bert Freudenberg wrote
On 04.09.2009, at 20:53, Dan Ingalls wrote:

Me too! And how well the ";" works with "." to separate statement is  
amazing. Others are imitating the cascade style by "chaining" but it  
looks weird and is limited at the same time; see e.g. this message I  
just got on a Python list:
Vasili Bykov gets some very readable statement separation for non-parenthesized chaining of keyword messages,  http://blog.3plus4.org/2007/09/ and discussed more fully http://blog.3plus4.org/2007/08/30/message-chains/.

In the context of Clamato, perhaps there is no real reason to tie up "," for string concat (just use "+" for that), and instead use it for parenth-free message chaining including keyword messages?

Reply | Threaded
Open this post in threaded view
|

Re: Clamato

Avi Bryant-2
On Thu, Nov 19, 2009 at 7:50 AM, Sophie424 <[hidden email]> wrote:

> Vasili Bykov gets some very readable statement separation for
> non-parenthesized chaining of keyword messages,
> http://blog.3plus4.org/2007/09/ and discussed more fully
> http://blog.3plus4.org/2007/08/30/message-chains/.
>
> In the context of Clamato, perhaps there is no real reason to tie up "," for
> string concat (just use "+" for that), and instead use it for parenth-free
> message chaining including keyword messages?

I would be very happy to accept a patch that implemented this.

Avi

Reply | Threaded
Open this post in threaded view
|

Re: Clamato

Stephen Pair
In reply to this post by Avi Bryant-2
Wow...I completely missed the Clamato announcement.  Fantastic!

On Fri, Sep 4, 2009 at 1:53 PM, Dan Ingalls <[hidden email]> wrote:
Hi, Avi -
 
>I don't love the @ syntax, but it has at least two advantages.  One is
>that, by essentially moving instance variable declarations into the
>methods, you can easily add instance variables to classes in other
>packages - Squeak has never had a good way to do this.  The other is
>that methods can be parsed and compiled with no context - unlike in
>Smalltalk, can identify instance variables vs. temps vs. globals
>without knowing anything about the class you are compiling the method
>for.  OTOH it's kind of ugly.

With all due respect, I agree ;-).

What if you used normal temp var declaration syntax, but just added an "@" to indicate instance variables...here is the counter example rewritten in that form..it seems more palatable to me and would have the advantages you mention:

<Example>

- open
| @root |
root := '#example' q.
self reload.
self.

- reload
| @root |
root contents: [:html | self renderOn: html].

<Counter>

+ superclass
Example.

- initialize
| @counter |
counter := 0.

- renderOn: html
| @counter |
html h3 with: counter.
html button
with: '+';
onClick: [counter := counter + 1. self reload].
html button
with: '-';
onClick: [counter := counter - 1. self reload].



123