||

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

Re: ||

stepharo
Really interesting discussion. I like pragmas but this is interesting to
see them challenged.
> Yes, but there end up being lots of naming conventions and they are
> non-obvious.  Whereas pragmas, because they are in-your-face in the
> methods in question, don't need conventions. They just need
> documenting ;-).
Thierry I'm skeptical that multiple protocol will save the problem
because you will rely on coding conventions.
And pragma is a clever tagging.

Stef


Reply | Threaded
Open this post in threaded view
|

Re: ||

stepharo
In reply to this post by Thierry Goubier

Le 6/2/15 19:15, Thierry Goubier a écrit :
> The good old finder has a pragmas search mode which allows for a bit
> of discoverability (pragma users), but it doesn't link to the code
> exploiting the pragmas.
>
> Do you know if we have something specific on SmartSuggestions for pragmas?

point taken. Indeed it would would be nice.

Stef


Reply | Threaded
Open this post in threaded view
|

Re: ||

stepharo
In reply to this post by Levente Uzonyi-2

> I would love to see an editor, which works on the AST directly - aka
> it maps the source code to AST nodes, and just updates the smallest
> possible subtree at each keystroke. Implementing such editor has it's
> challenges ofc, like typing a single character can invalidate the
> whole code, but the editor should keep the AST somehow in that case too.

Me too and I want pretty print as you type :)
A student will probably want to start that adventure so we will have fun.

>
>>
>> Another way to see it: How would the original Smalltalk be designed
>> if they would have had 4GB RAM in 1978?
>>
>> What fascinates me still is that Smalltalk used the existing
>> resources (even building their own machines) to an
>> extreme, while today we are obsessed to find reasons why we can not
>> do anything that makes the system
>> slower or use more memory than yesterday. And that even with
>> resources growing every year…
>>
>> This is why we e.g. now have a meta object describing every instance
>> variable in Pharo. I am sure there are people
>> who will see these ~7000 objects as pure waste… while I would say
>> that we have already *now* the resources to be
>> even more radical.
>
> I think this is a different thing. Improvements are always welcome, as
> long as they don't step on your toes.
>
> About Slots: I don't see their advantages yet (other than bitfields,
> but those are so rare in Smalltalk that I implement them causes no
> trouble. And they are just an optimization over using multiple fields.).
>
> Levente
>
>>
>>     Marcus
>>
>>
>>


Reply | Threaded
Open this post in threaded view
|

Re: ||

Thierry Goubier
In reply to this post by Eliot Miranda-2


2015-02-06 18:29 GMT+01:00 Eliot Miranda <[hidden email]>:


On Fri, Feb 6, 2015 at 1:58 AM, Thierry Goubier <[hidden email]> wrote:
Hi Eliot,

maybe I'll frame the core question a bit differently, thanks to your explanations.

I see pragmas used mainly for two things:

1- expressing a link to some metadata used by low level tools: compiler, C lang generator, etc... primitives for me are part of that. Kind of neat to see that unified.

There's a third use that is, I think, the most powerful.  Maybe you see this as the same as 1, but I don't.  The method is a component to be included in some larger structure, e.g. it is an action method on a menu, or it is an implementation of a pane in an inspector.  The pragma is the message to be sent to the object that manipulates that larger structure to add the method to it.  This is how menu pragmas work in VW.  There is an object called a MenuBuilder.  To add a method to a menu (and which menu is described by the pragma) the menu builder sets the method as its current method and then performs the pragma.  The parameters in the pragma allow the MenuBuilder to add the method in the right way to the menu.  But the execution of the pragma is what actually adds the mehtod to the menu.  So its a combination of specification and execution.

You mean as a sort of lightweight command object? Pharo uses that for its world menu, Nautilus for its menus, and probably in a few other places. I also like to define command objects for that purpose, because it gives you more flexibility and power while keeping all concerns together: complex commands depending on the context of their creator, having both a menu entry and a shortcut, controlling whether they are enabled or not... I also like command objects because they usually force a bit of a dedicated category for them, and may avoid a spread of pragmas tagged methods left and right in the package.
 


I have no problem with your criticism of pragmas used for categorisation.  Method categories are already there and sometimes much more appropriate than pragmas.  For example, in the SPur bootstrap the methods to be added or modified in Spur are included in categories of SpurBootstrapPrototypes and its subclasses.  If there were pragmas in these methods then the pragmas would be copied into Spur, which is not at all what I want.  Instead I copy across the methods in the relevant categories.

But this "not a complete solution" feels to me an unfair criticism.  Pragmas are what they are and they can do a lot.  But no part of the system does everything.  A system is composed of components.

I agree with that, and the fact that well, maybe, someone will come along with something better :)

Thierry

Reply | Threaded
Open this post in threaded view
|

Re: ||

Eliot Miranda-2


On Fri, Feb 6, 2015 at 2:12 PM, Thierry Goubier <[hidden email]> wrote:


2015-02-06 18:29 GMT+01:00 Eliot Miranda <[hidden email]>:


On Fri, Feb 6, 2015 at 1:58 AM, Thierry Goubier <[hidden email]> wrote:
Hi Eliot,

maybe I'll frame the core question a bit differently, thanks to your explanations.

I see pragmas used mainly for two things:

1- expressing a link to some metadata used by low level tools: compiler, C lang generator, etc... primitives for me are part of that. Kind of neat to see that unified.

There's a third use that is, I think, the most powerful.  Maybe you see this as the same as 1, but I don't.  The method is a component to be included in some larger structure, e.g. it is an action method on a menu, or it is an implementation of a pane in an inspector.  The pragma is the message to be sent to the object that manipulates that larger structure to add the method to it.  This is how menu pragmas work in VW.  There is an object called a MenuBuilder.  To add a method to a menu (and which menu is described by the pragma) the menu builder sets the method as its current method and then performs the pragma.  The parameters in the pragma allow the MenuBuilder to add the method in the right way to the menu.  But the execution of the pragma is what actually adds the mehtod to the menu.  So its a combination of specification and execution.

You mean as a sort of lightweight command object? Pharo uses that for its world menu, Nautilus for its menus, and probably in a few other places. I also like to define command objects for that purpose, because it gives you more flexibility and power while keeping all concerns together: complex commands depending on the context of their creator, having both a menu entry and a shortcut, controlling whether they are enabled or not... I also like command objects because they usually force a bit of a dedicated category for them, and may avoid a spread of pragmas tagged methods left and right in the package.

Yes, a Message instance is a command object, pragmas are Message instances, therefore pragmas are command objects.  So using pragmas to associate menu action methods with their menus embeds the relevant command objects in the menu action methods.


I have no problem with your criticism of pragmas used for categorisation.  Method categories are already there and sometimes much more appropriate than pragmas.  For example, in the SPur bootstrap the methods to be added or modified in Spur are included in categories of SpurBootstrapPrototypes and its subclasses.  If there were pragmas in these methods then the pragmas would be copied into Spur, which is not at all what I want.  Instead I copy across the methods in the relevant categories.

But this "not a complete solution" feels to me an unfair criticism.  Pragmas are what they are and they can do a lot.  But no part of the system does everything.  A system is composed of components.

I agree with that, and the fact that well, maybe, someone will come along with something better :)

Thierry




--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: ||

Thierry Goubier
In reply to this post by Eliot Miranda-2


2015-02-06 18:41 GMT+01:00 Eliot Miranda <[hidden email]>:

Or are you talking about the lack of class pragmas?  This is a point.  But classes already have an executable hook they can use for system modification, their class-side initialize and obsolete methods.  That's been used for a long time to address system modification needs on installing and removing classes.  So form that perspective there's less of a need to class pragmas.  Instead we're focussing on more specialised class definition facilities such as slots, which are intrinsic to classes, i.e. define the class itself, rather than pragmas, which are extrinsic to methods in that they define how methods interact in the system outside themselves.

Maybe what you are saying here holds what I am longing for. Something as simple and as well defined as aClass class>>initialize (simple, solve-it-all mechanism for all initialization needs in a class, full smalltalk based so easily discoverable) or now the class slots, but applied to methods and their metadata. Pragmas are a first step towards that, but I have a feeling we could do it better (and it seems, with some of the changes coming such as traces, in-image optimisations, breakpoints, etc... it may be usefull or overgrow the pragmas).

Thierry
Reply | Threaded
Open this post in threaded view
|

Re: ||

Thierry Goubier
In reply to this post by stepharo


2015-02-06 22:00 GMT+01:00 stepharo <[hidden email]>:
Really interesting discussion. I like pragmas but this is interesting to see them challenged.

Thanks. It's a pleasure to discuss that way :)
 
Yes, but there end up being lots of naming conventions and they are non-obvious.  Whereas pragmas, because they are in-your-face in the methods in question, don't need conventions. They just need documenting ;-).
Thierry I'm skeptical that multiple protocol will save the problem because you will rely on coding conventions.

Pragma as well: just explain the conventions behind the gtInspector pragmas, for example.

But give me multiple protocols and I'll show you the same conventions rewritten in less lines (and a slightly more efficient code).
 
And pragma is a clever tagging.

Then maybe we should remove protocols and replace them with pragmas :)

Thierry
 

Stef



Reply | Threaded
Open this post in threaded view
|

Re: ||

Stephan Eggermont-3
In reply to this post by Frank Shearar-3
On 05/02/15 16:52, Frank Shearar wrote:

> On 5 February 2015 at 15:35, Levente Uzonyi <[hidden email]> wrote:
>> Rebuilding the whole AST after every keystroke is possible, but keeping it
>> real-time is a bit challenging.
>>
>> I would love to see an editor, which works on the AST directly - aka it maps
>> the source code to AST nodes, and just updates the smallest possible subtree
>> at each keystroke. Implementing such editor has it's challenges ofc, like
>> typing a single character can invalidate the whole code, but the editor
>> should keep the AST somehow in that case too.
>
> C#'s Roslyn does this:
> http://blogs.msdn.com/b/ericlippert/archive/2012/06/08/persistence-facades-and-roslyn-s-red-green-trees.aspx

This is an interesting approach. Their problem is not just updating the
AST after every keystroke but keeping usable performance when doing code
rewriting/refactoring.

My first Macintosh, a SE/30 with a 16 MHz 68030, was able to do this
with Think Pascal (by Mel Conway) 25 years ago. On my next machine,
a 25 MHz 68040LC was fast enough...

Stephan


Reply | Threaded
Open this post in threaded view
|

Re: ||

kilon.alios
In reply to this post by Thierry Goubier
Personally I don't like Pragmas, they have not convinced me so far that they fit the style of Smalltalk syntax. I have to confess though I never liked descriptive elements and languages . 

About python decorators I disagree that are similar to pragmas. Pragmas are focused on being descriptive , python decorators are descriptive as by product. The main focus of python decorators is to shorten code by introducing syntactic sugar. 

I agree though this is a very interesting discussion and I dont understand most of the things stated here so I leave an open door and mind for pragmas. Maybe one day I will "get it". 

On Sat, Feb 7, 2015 at 10:02 AM, Thierry Goubier <[hidden email]> wrote:


2015-02-06 22:00 GMT+01:00 stepharo <[hidden email]>:
Really interesting discussion. I like pragmas but this is interesting to see them challenged.

Thanks. It's a pleasure to discuss that way :)
 
Yes, but there end up being lots of naming conventions and they are non-obvious.  Whereas pragmas, because they are in-your-face in the methods in question, don't need conventions. They just need documenting ;-).
Thierry I'm skeptical that multiple protocol will save the problem because you will rely on coding conventions.

Pragma as well: just explain the conventions behind the gtInspector pragmas, for example.

But give me multiple protocols and I'll show you the same conventions rewritten in less lines (and a slightly more efficient code).
 
And pragma is a clever tagging.

Then maybe we should remove protocols and replace them with pragmas :)

Thierry
 

Stef




Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: ||

David T. Lewis
In reply to this post by Marcus Denker-4
On Thu, Feb 05, 2015 at 01:54:51PM +0100, Marcus Denker wrote:

>
> > On 05 Feb 2015, at 10:12, Marcus Denker <[hidden email]> wrote:
> >>
> >> On 05 Feb 2015, at 10:04, Marcus Denker <[hidden email]> wrote:
> >
> > Another way to see it: How would the original Smalltalk be designed if they would have had 4GB RAM in 1978?
> >
> > What fascinates me still is that Smalltalk used the existing resources (even building their own machines) to an
> > extreme, while today we are obsessed to find reasons why we can not do anything that makes the system
> > slower or use more memory than yesterday. And that even with resources growing every year???
> >
> > This is why we e.g. now have a meta object describing every instance variable in Pharo. I am sure there are people
> > who will see these ~7000 objects as pure waste??? while I would say that we have already *now* the resources to be
> > even more radical.
> >
>
> Seemingly I still can not explain what I mean in away that people get it, so please just ignore this mail.
>
> Marcus
>

Your point makes good sense to me. In 1978, a system in which a low-level
integer was represented as an object with behavior would have been perceived
as a rediculously wasteful idea. And can you imagine someone seriously
suggesting something so wasteful as automatic memory management?

So if the "same" system was being designed today, it might very well include
new concepts that today are perceived as wasteful. Some of those concepts
might turn out to be very good thing once we get used to them.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: ||

hernanmd
In reply to this post by kilon.alios

2015-02-07 5:59 GMT-03:00 kilon alios <[hidden email]>:
Personally I don't like Pragmas, they have not convinced me so far that they fit the style of Smalltalk syntax. I have to confess though I never liked descriptive elements and languages . 


Me neither. Actually the pragma idea is not wrong per se, it is the tag syntax to write them which bothers me. Because the world can be described with tags if you start that path.
There are other ways to add metadata to methods. Without tagging.
And they don't need to be in the method pane itself.
It is like having to specify protocol because there is no list pane to create them.

Hernán
 
About python decorators I disagree that are similar to pragmas. Pragmas are focused on being descriptive , python decorators are descriptive as by product. The main focus of python decorators is to shorten code by introducing syntactic sugar. 

I agree though this is a very interesting discussion and I dont understand most of the things stated here so I leave an open door and mind for pragmas. Maybe one day I will "get it". 



 

On Sat, Feb 7, 2015 at 10:02 AM, Thierry Goubier <[hidden email]> wrote:


2015-02-06 22:00 GMT+01:00 stepharo <[hidden email]>:
Really interesting discussion. I like pragmas but this is interesting to see them challenged.

Thanks. It's a pleasure to discuss that way :)
 
Yes, but there end up being lots of naming conventions and they are non-obvious.  Whereas pragmas, because they are in-your-face in the methods in question, don't need conventions. They just need documenting ;-).
Thierry I'm skeptical that multiple protocol will save the problem because you will rely on coding conventions.

Pragma as well: just explain the conventions behind the gtInspector pragmas, for example.

But give me multiple protocols and I'll show you the same conventions rewritten in less lines (and a slightly more efficient code).
 
And pragma is a clever tagging.

Then maybe we should remove protocols and replace them with pragmas :)

Thierry
 

Stef





Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: ||

Andreas Wacknitz
In reply to this post by David T. Lewis

> Am 07.02.2015 um 16:18 schrieb David T. Lewis <[hidden email]>:
>
> On Thu, Feb 05, 2015 at 01:54:51PM +0100, Marcus Denker wrote:
>>
>>> On 05 Feb 2015, at 10:12, Marcus Denker <[hidden email]> wrote:
>>>>
>>>> On 05 Feb 2015, at 10:04, Marcus Denker <[hidden email]> wrote:
>>>
>>> Another way to see it: How would the original Smalltalk be designed if they would have had 4GB RAM in 1978?
>>>
>>> What fascinates me still is that Smalltalk used the existing resources (even building their own machines) to an
>>> extreme, while today we are obsessed to find reasons why we can not do anything that makes the system
>>> slower or use more memory than yesterday. And that even with resources growing every year???
>>>
>>> This is why we e.g. now have a meta object describing every instance variable in Pharo. I am sure there are people
>>> who will see these ~7000 objects as pure waste??? while I would say that we have already *now* the resources to be
>>> even more radical.
>>>
>>
>> Seemingly I still can not explain what I mean in away that people get it, so please just ignore this mail.
>>
>> Marcus
>>
>
> Your point makes good sense to me. In 1978, a system in which a low-level
> integer was represented as an object with behavior would have been perceived
> as a rediculously wasteful idea. And can you imagine someone seriously
> suggesting something so wasteful as automatic memory management?
>
> So if the "same" system was being designed today, it might very well include
> new concepts that today are perceived as wasteful. Some of those concepts
> might turn out to be very good thing once we get used to them.
The times have changed. Today waste seems to be a requirement.
Whatever application you have - reimplement it using „web technologies“.
Whatever data you have - store it in „the cloud“ and tunnel its transportation over port 80,
gain extra points for using XML here.

Today, beautiful small things like Smalltalk are ignored by the masses and being laughed at.

Andreas
Reply | Threaded
Open this post in threaded view
|

Re: ||

kilon.alios
In reply to this post by hernanmd
I agree, my objection too is how it looks syntax wise. As I said I don't understand pragmas deeply enough to make a decision if I want them removed or not. 

Tag wise, well I think a tag should be an IDE and not a language feature. But thats my personal preference. Protocols for me at least is another way to tag things. 

As I said in the past I would prefer a more elaborate system of tagging for methods and classes similar how Stackoverflow questions work of default and custom tags. 

On the other hand, people like different things so I never made a big deal out of it.  So for now I just tolerate pragmas and they do tolerate me :D 

On Sat, Feb 7, 2015 at 5:41 PM, Hernán Morales Durand <[hidden email]> wrote:

2015-02-07 5:59 GMT-03:00 kilon alios <[hidden email]>:
Personally I don't like Pragmas, they have not convinced me so far that they fit the style of Smalltalk syntax. I have to confess though I never liked descriptive elements and languages . 


Me neither. Actually the pragma idea is not wrong per se, it is the tag syntax to write them which bothers me. Because the world can be described with tags if you start that path.
There are other ways to add metadata to methods. Without tagging.
And they don't need to be in the method pane itself.
It is like having to specify protocol because there is no list pane to create them.

Hernán
 
About python decorators I disagree that are similar to pragmas. Pragmas are focused on being descriptive , python decorators are descriptive as by product. The main focus of python decorators is to shorten code by introducing syntactic sugar. 

I agree though this is a very interesting discussion and I dont understand most of the things stated here so I leave an open door and mind for pragmas. Maybe one day I will "get it". 



 

On Sat, Feb 7, 2015 at 10:02 AM, Thierry Goubier <[hidden email]> wrote:


2015-02-06 22:00 GMT+01:00 stepharo <[hidden email]>:
Really interesting discussion. I like pragmas but this is interesting to see them challenged.

Thanks. It's a pleasure to discuss that way :)
 
Yes, but there end up being lots of naming conventions and they are non-obvious.  Whereas pragmas, because they are in-your-face in the methods in question, don't need conventions. They just need documenting ;-).
Thierry I'm skeptical that multiple protocol will save the problem because you will rely on coding conventions.

Pragma as well: just explain the conventions behind the gtInspector pragmas, for example.

But give me multiple protocols and I'll show you the same conventions rewritten in less lines (and a slightly more efficient code).
 
And pragma is a clever tagging.

Then maybe we should remove protocols and replace them with pragmas :)

Thierry
 

Stef






Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: ||

kilon.alios
In reply to this post by Andreas Wacknitz
And none of the XML and web technologies sell as much as Angry Birds and Candy Crash Saga :D 

I think you underestimate people. True Web is very popular, but lets not forget all the promises a decade ago that we will completely move to the cloud in a few years and we are still desktop all the way. Only desktop has moved to mobile devices which none could predict it at the time. 

On the other hand Smalltalk was not rejected because it was beautiful , it was rejected because it failed to adjust to current demands. It remained a good proof of concept and not much more than that. It opened the door , but never truly entered the room. 

On Sat, Feb 7, 2015 at 6:01 PM, Andreas Wacknitz <[hidden email]> wrote:

> Am 07.02.2015 um 16:18 schrieb David T. Lewis <[hidden email]>:
>
> On Thu, Feb 05, 2015 at 01:54:51PM +0100, Marcus Denker wrote:
>>
>>> On 05 Feb 2015, at 10:12, Marcus Denker <[hidden email]> wrote:
>>>>
>>>> On 05 Feb 2015, at 10:04, Marcus Denker <[hidden email]> wrote:
>>>
>>> Another way to see it: How would the original Smalltalk be designed if they would have had 4GB RAM in 1978?
>>>
>>> What fascinates me still is that Smalltalk used the existing resources (even building their own machines) to an
>>> extreme, while today we are obsessed to find reasons why we can not do anything that makes the system
>>> slower or use more memory than yesterday. And that even with resources growing every year???
>>>
>>> This is why we e.g. now have a meta object describing every instance variable in Pharo. I am sure there are people
>>> who will see these ~7000 objects as pure waste??? while I would say that we have already *now* the resources to be
>>> even more radical.
>>>
>>
>> Seemingly I still can not explain what I mean in away that people get it, so please just ignore this mail.
>>
>>      Marcus
>>
>
> Your point makes good sense to me. In 1978, a system in which a low-level
> integer was represented as an object with behavior would have been perceived
> as a rediculously wasteful idea. And can you imagine someone seriously
> suggesting something so wasteful as automatic memory management?
>
> So if the "same" system was being designed today, it might very well include
> new concepts that today are perceived as wasteful. Some of those concepts
> might turn out to be very good thing once we get used to them.
The times have changed. Today waste seems to be a requirement.
Whatever application you have - reimplement it using „web technologies“.
Whatever data you have - store it in „the cloud“ and tunnel its transportation over port 80,
gain extra points for using XML here.

Today, beautiful small things like Smalltalk are ignored by the masses and being laughed at.

Andreas

Reply | Threaded
Open this post in threaded view
|

Re: ||

Eliot Miranda-2
In reply to this post by hernanmd
Hi Hernan,

On Sat, Feb 7, 2015 at 7:41 AM, Hernán Morales Durand <[hidden email]> wrote:

2015-02-07 5:59 GMT-03:00 kilon alios <[hidden email]>:
Personally I don't like Pragmas, they have not convinced me so far that they fit the style of Smalltalk syntax. I have to confess though I never liked descriptive elements and languages . 


Me neither. Actually the pragma idea is not wrong per se, it is the tag syntax to write them which bothers me. Because the world can be described with tags if you start that path.

How exactly is the syntax wrong?
The <literalMessagePattern> syntax predates pragmas.  It was used first for numeric primitives in Smalltalk-76 or Smalltalk-80.  Squeak extended it with primitive:module:.  I and others extended it to include arbitrary literal message patterns.  The syntax of a literal message pattern is the syntax of a send with no receiver and only literal arguments.  The use of this syntax means
a) no new syntax
b) each pragma is potentially executable
c) methods using specific pragmas can be found using "find senders"
d) the execution side of a pragma can be found using "find implementors"

So what's wrong with that?  How is it wrong to use a common Smalltalk object, a Message, that is well-supported in the system, for method metadata?

 
There are other ways to add metadata to methods. Without tagging.

Haven't we discussed that?  Putting metadata off to the side introduces a bookkeeping problem.  It is a bad idea.
 
And they don't need to be in the method pane itself.

For some kinds of metadata, for metadata with semantics, not just a documentary function, it is important for the metadata to be obvious.  No one has argued for hiding the primitive specification off-to-the-side.  "Need" is a poor criticism here because using turing equivalence lots of things don't "need" to be the way they are.  Instead why not ask what are the pros and cons?

 
It is like having to specify protocol because there is no list pane to create them.

I disagree.  When the pragma is specifying type information, specifying that the method is an action on a specific menu, is a pane in an inspector, and many other uses, it is essential that that information be represented, and putting it in a one-off bookkeeping system is a bad idea.  We're not talking about simple documentary metadata like author, category etc.  We're using pragmas for semantics, semantics of the method that are outside of its execution semantics, semantics about how the method fits in the broader system.  And putting that in non-obvious places is a bad idea.  



Hernán
 
About python decorators I disagree that are similar to pragmas. Pragmas are focused on being descriptive , python decorators are descriptive as by product. The main focus of python decorators is to shorten code by introducing syntactic sugar. 

Kilon, pragmas are not limited to being descriptive.
 

I agree though this is a very interesting discussion and I dont understand most of the things stated here so I leave an open door and mind for pragmas. Maybe one day I will "get it". 

That would be nice :) 



 

On Sat, Feb 7, 2015 at 10:02 AM, Thierry Goubier <[hidden email]> wrote:


2015-02-06 22:00 GMT+01:00 stepharo <[hidden email]>:
Really interesting discussion. I like pragmas but this is interesting to see them challenged.

Thanks. It's a pleasure to discuss that way :)
 
Yes, but there end up being lots of naming conventions and they are non-obvious.  Whereas pragmas, because they are in-your-face in the methods in question, don't need conventions. They just need documenting ;-).
Thierry I'm skeptical that multiple protocol will save the problem because you will rely on coding conventions.

Pragma as well: just explain the conventions behind the gtInspector pragmas, for example.

But give me multiple protocols and I'll show you the same conventions rewritten in less lines (and a slightly more efficient code).
 
And pragma is a clever tagging.

Then maybe we should remove protocols and replace them with pragmas :)

Thierry
 

Stef








--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: ||

kilon.alios
"Kilon, pragmas are not limited to being descriptive."

Ok , I went back and carefully read your posts. I did not noticed that pragmas are executable too, I stand corrected. It appears I underestimated Pragmas, after reading your posts I see where you going with this. Especially the part of adding methods to objects like menu entries definitely makes some sense. 

The more I think how I would do this, the more I start to appreciate pragmas. For example I would attach some variables to Object class to create a dictionary that will manage meta data for each method. That would move the definition of the method meta data outside the method definition itself but I am not sure if that is such a good thing afterall. 

I think I will let myself get a few years more experience in Pharo to make up my mind and fully appreciate pragmas. 
Reply | Threaded
Open this post in threaded view
|

Re: ||

Thierry Goubier
In reply to this post by Eliot Miranda-2


2015-02-07 18:48 GMT+01:00 Eliot Miranda <[hidden email]>:
Hi Hernan,

On Sat, Feb 7, 2015 at 7:41 AM, Hernán Morales Durand <[hidden email]> wrote:

2015-02-07 5:59 GMT-03:00 kilon alios <[hidden email]>:
Personally I don't like Pragmas, they have not convinced me so far that they fit the style of Smalltalk syntax. I have to confess though I never liked descriptive elements and languages . 


Me neither. Actually the pragma idea is not wrong per se, it is the tag syntax to write them which bothers me. Because the world can be described with tags if you start that path.

How exactly is the syntax wrong?
The <literalMessagePattern> syntax predates pragmas.  It was used first for numeric primitives in Smalltalk-76 or Smalltalk-80.  Squeak extended it with primitive:module:.  I and others extended it to include arbitrary literal message patterns.  The syntax of a literal message pattern is the syntax of a send with no receiver and only literal arguments.  The use of this syntax means
a) no new syntax
b) each pragma is potentially executable
c) methods using specific pragmas can be found using "find senders"
d) the execution side of a pragma can be found using "find implementors"

So what's wrong with that?  How is it wrong to use a common Smalltalk object, a Message, that is well-supported in the system, for method metadata?

The point was: descriptive and the world could be described  by tags :) Message syntax for pragmas is just a consequence of the original primitive syntax, nothing else (I.e. natural syntax extension). Given how it is used and that the "potentially executable" is just that, potential, array literals would work just as well (and I'm nearly sure that a todays design for pragmas would give us something like STON content :))
 

 
There are other ways to add metadata to methods. Without tagging.

Haven't we discussed that?  Putting metadata off to the side introduces a bookkeeping problem.  It is a bad idea.

And pragmas only partially address that.

Imagine that Sista works, that it has dozens of tuning points for a method (int, no recurse, vect, is a reduce, openCL, thread-safe, hot point, this loop should be enrolled) do you imagine writing all that into the method to guide Sista with pragmas? You'll end up in exactly the same situation as OpenMP 4, where it is possible to write programs with more #pragma lines than C/C++ code.

(And C #pragmas are clearly more powerfull than Smalltalk's, since they are not required to be at the start of the function only)
 
 
And they don't need to be in the method pane itself.

For some kinds of metadata, for metadata with semantics, not just a documentary function, it is important for the metadata to be obvious.  No one has argued for hiding the primitive specification off-to-the-side.  "Need" is a poor criticism here because using turing equivalence lots of things don't "need" to be the way they are.  Instead why not ask what are the pros and cons?

 
It is like having to specify protocol because there is no list pane to create them.

I disagree.  When the pragma is specifying type information, specifying that the method is an action on a specific menu, is a pane in an inspector, and many other uses, it is essential that that information be represented, and putting it in a one-off bookkeeping system is a bad idea.  We're not talking about simple documentary metadata like author, category etc.  We're using pragmas for semantics, semantics of the method that are outside of its execution semantics, semantics about how the method fits in the broader system.  And putting that in non-obvious places is a bad idea.  

Good, you're giving my favorite examples for what pragmas are redundant :)

The method with the menu pragma is named "worldMenuCommand" ...

The method with the gtInspector pragma is named "gtInspectorPresentation..."

Additionally, as I told you before: the pragma semantic isn't in the method... It's somewhere else in the system and senders of that pragma doesn't get it.

Just have a look at OmniBrowser and tell me that you don't understand where the menu commands are :)
 
Thierry
Reply | Threaded
Open this post in threaded view
|

Re: ||

Eliot Miranda-2


On Sat, Feb 7, 2015 at 10:21 AM, Thierry Goubier <[hidden email]> wrote:


2015-02-07 18:48 GMT+01:00 Eliot Miranda <[hidden email]>:
Hi Hernan,

On Sat, Feb 7, 2015 at 7:41 AM, Hernán Morales Durand <[hidden email]> wrote:

2015-02-07 5:59 GMT-03:00 kilon alios <[hidden email]>:
Personally I don't like Pragmas, they have not convinced me so far that they fit the style of Smalltalk syntax. I have to confess though I never liked descriptive elements and languages . 


Me neither. Actually the pragma idea is not wrong per se, it is the tag syntax to write them which bothers me. Because the world can be described with tags if you start that path.

How exactly is the syntax wrong?
The <literalMessagePattern> syntax predates pragmas.  It was used first for numeric primitives in Smalltalk-76 or Smalltalk-80.  Squeak extended it with primitive:module:.  I and others extended it to include arbitrary literal message patterns.  The syntax of a literal message pattern is the syntax of a send with no receiver and only literal arguments.  The use of this syntax means
a) no new syntax
b) each pragma is potentially executable
c) methods using specific pragmas can be found using "find senders"
d) the execution side of a pragma can be found using "find implementors"

So what's wrong with that?  How is it wrong to use a common Smalltalk object, a Message, that is well-supported in the system, for method metadata?

The point was: descriptive and the world could be described  by tags :) Message syntax for pragmas is just a consequence of the original primitive syntax, nothing else (I.e. natural syntax extension). Given how it is used and that the "potentially executable" is just that, potential, array literals would work just as well (and I'm nearly sure that a todays design for pragmas would give us something like STON content :))

Array literals are not executable.  They are literals.  They need an interpreter to add semantics.  This is one of the reasons why Spec is poor.  Pragmas are Message instances.  They respond to sendTo:/sentTo:.  STON is not executable, it needs an interpreter.

There are other ways to add metadata to methods. Without tagging.

Haven't we discussed that?  Putting metadata off to the side introduces a bookkeeping problem.  It is a bad idea.

And pragmas only partially address that.

Partially?  It completely solves the issue of keeping metadata associated with a method.

Imagine that Sista works, that it has dozens of tuning points for a method (int, no recurse, vect, is a reduce, openCL, thread-safe, hot point, this loop should be enrolled) do you imagine writing all that into the method to guide Sista with pragmas? You'll end up in exactly the same situation as OpenMP 4, where it is possible to write programs with more #pragma lines than C/C++ code.

One doesn't need a line per option.  One can use... literal arrays

    someImportantMethod
        <sistaTuningHints: #(threadSafe unroll)>

but for Sista we imagine very few tuning options, perhaps only one, which is to say to the optimizer optimize this method even if it doesn't show up as a hot spot.  Sista is /not/ going to look like gcc.

 
(And C #pragmas are clearly more powerfull than Smalltalk's, since they are not required to be at the start of the function only)

Sure.  Pragmas associate with methods, not statements.

 
And they don't need to be in the method pane itself.

For some kinds of metadata, for metadata with semantics, not just a documentary function, it is important for the metadata to be obvious.  No one has argued for hiding the primitive specification off-to-the-side.  "Need" is a poor criticism here because using turing equivalence lots of things don't "need" to be the way they are.  Instead why not ask what are the pros and cons?

 
It is like having to specify protocol because there is no list pane to create them.

I disagree.  When the pragma is specifying type information, specifying that the method is an action on a specific menu, is a pane in an inspector, and many other uses, it is essential that that information be represented, and putting it in a one-off bookkeeping system is a bad idea.  We're not talking about simple documentary metadata like author, category etc.  We're using pragmas for semantics, semantics of the method that are outside of its execution semantics, semantics about how the method fits in the broader system.  And putting that in non-obvious places is a bad idea.  

Good, you're giving my favorite examples for what pragmas are redundant :)

The method with the menu pragma is named "worldMenuCommand" ...

I don't see examples of this in the pharo 4 image I have to hand.  What's the full selector?
 
The method with the gtInspector pragma is named "gtInspectorPresentation..."

This one is ok.  The pragma both says the method is a pane in a glamour inspector, and says what the order is relative to others.  One thing that's broken is that the finder doesn't find any senders.  Another thing is that the pragma doesn't do anything.  If the Glamour inspector added panes to itself by using sentTo: to evaluate the pragma then when you did "implementors" you'd find the builder.


So those examples are not taking full advantage.  In VW they're more interesting, e.g.
 
searchForStringInSource
"Spawn a Browser on all methods which contain a specified string."

<menuItem: #(#MethodsWithPhraseDot #menus 'Methods with &Phrase...')
nameKey: nil
menu: #(#listMenu #browse) 
position: 21.03 >
...

which says which sub menu it is in (listMenu browse), where it is relative to other entries (21.03), what its hot key is (P). And MenuAutomaticGeneraotr implements the pragma (which shows up though the "implementors" menu on the menu pragma method):

menuItem: label nameKey: key menu: menuIDs position: position "If the method is to be inserted into our menu, create a MenuItem, otherwise answer nil." | realLabel | menuIDs first = menuName ifFalse: [^nil]. realLabel := self decodeLabel: label. ^Array with: ((MenuItem labeled: realLabel) nameKey: key) with: (menuIDs copyFrom: 2 to: menuIDs size) with: position


Additionally, as I told you before: the pragma semantic isn't in the method... It's somewhere else in the system and senders of that pragma doesn't get it.

I know that very well.  If things are done right, that the finder will find pragmas via "senders", and if the designer has chosen to implement the pragma in some processing object, then the link is made.  But I disagree that the semantic is entirely elsewhere in the system.  The /implementation/ is elsewhere in the system.  The semantic is in the pragma, in exactly the same way as a message specifies an operation to be performed and a method specifies an implementation, because... pragmas are messages.


Just have a look at OmniBrowser and tell me that you don't understand where the menu commands are :)

I don't want to criticise OmniBrowser, but if pragmas are used in the pattern above those relationships become clear.  

Thierry
--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: ||

hernanmd
In reply to this post by Eliot Miranda-2
Hi Eliot,

2015-02-07 14:48 GMT-03:00 Eliot Miranda <[hidden email]>:
Hi Hernan,

On Sat, Feb 7, 2015 at 7:41 AM, Hernán Morales Durand <[hidden email]> wrote:

2015-02-07 5:59 GMT-03:00 kilon alios <[hidden email]>:
Personally I don't like Pragmas, they have not convinced me so far that they fit the style of Smalltalk syntax. I have to confess though I never liked descriptive elements and languages . 


Me neither. Actually the pragma idea is not wrong per se, it is the tag syntax to write them which bothers me. Because the world can be described with tags if you start that path.

How exactly is the syntax wrong?

I am not saying syntax is wrong, I just don't like it because:

1) Adds another level of representation inside an already reflective system.
2) It could be done with plain common message sends.
3) Should be (to me) "hidden" from method pane, and displayed by a specific tool inside the system browser.
 
The <literalMessagePattern> syntax predates pragmas.  It was used first for numeric primitives in Smalltalk-76 or Smalltalk-80.  Squeak extended it with primitive:module:.  I and others extended it to include arbitrary literal message patterns.  The syntax of a literal message pattern is the syntax of a send with no receiver and only literal arguments. 
The use of this syntax means
a) no new syntax
b) each pragma is potentially executable
c) methods using specific pragmas can be found using "find senders"
d) the execution side of a pragma can be found using "find implementors"

So what's wrong with that?  How is it wrong to use a common Smalltalk object, a Message, that is well-supported in the system, for method metadata?


I get that pragmas are messages, but they assume an implicit receiver, which actually depends on context. If I understood right with pragmas always receiver = destination?  If you change things in the communication model (receiver, sender, message, etc.), by removing or adding elements, you have a loss in the message because it gets harder to reconstruct the message send.

Consider

<eventRegistration>
| eventRegistration |
{ eventRegistration }.
self eventRegistration.

which of them "it sounds like" you cannot infer their purpose?

To me the first because you need the context MyClass>>methodName
and you need to browse the pragma to get its purpose.


 
There are other ways to add metadata to methods. Without tagging.

Haven't we discussed that?  Putting metadata off to the side introduces a bookkeeping problem.  It is a bad idea.

Yes, but I still have a lot of doubts about feedback with pragmas (I hope you view them as constructive criticism).

Is like pragmas assume there is always a perfect message transaction.
How can I halt the execution of a specific pragma? Can I write <myPragma halt>?
How do I know if it will get executed? Is <shortcut> a functional pragma?
How do I distinguis any pragma from being functional or "documentation"?
 
 
And they don't need to be in the method pane itself.

For some kinds of metadata, for metadata with semantics, not just a documentary function, it is important for the metadata to be obvious. 

I think this depends on context. Because your work could be towards low-level machinery details or software reenginering, doesn't mean that we all need to view compiler directives, functional and structural annotations, etc.

And if I can write some prediction... When someone invents automatic annotation (like happens now with genomes) and decides it will be cool to have them in the image (because you will gain performance, more reflective capabilitites, etc) methods could explode with pragmas to the point gets to be annoying to browse any method. Then the tool will have to be built by need.
 
No one has argued for hiding the primitive specification off-to-the-side.  "Need" is a poor criticism here because using turing equivalence lots of things don't "need" to be the way they are.  Instead why not ask what are the pros and cons?


Ok, many of us knows the pros. I have been using pragmas for a while.
But if we stop discussing then it will never adapt to new ideas.
So you may want to share your view of cons too :)

 
It is like having to specify protocol because there is no list pane to create them.

I disagree.  When the pragma is specifying type information, specifying that the method is an action on a specific menu, is a pane in an inspector, and many other uses, it is essential that that information be represented, and putting it in a one-off bookkeeping system is a bad idea.  We're not talking about simple documentary metadata like author, category etc. 

Well, I think documentary metadata is tremendously complex.
 
We're using pragmas for semantics, semantics of the method that are outside of its execution semantics, semantics about how the method fits in the broader system.  And putting that in non-obvious places is a bad idea.  


I agree. But obvious could be a place where can be located by a method though not necessarily visible.

Cheers,

Hernán

 


Hernán
 
About python decorators I disagree that are similar to pragmas. Pragmas are focused on being descriptive , python decorators are descriptive as by product. The main focus of python decorators is to shorten code by introducing syntactic sugar. 

Kilon, pragmas are not limited to being descriptive.
 

I agree though this is a very interesting discussion and I dont understand most of the things stated here so I leave an open door and mind for pragmas. Maybe one day I will "get it". 

That would be nice :) 



 

On Sat, Feb 7, 2015 at 10:02 AM, Thierry Goubier <[hidden email]> wrote:


2015-02-06 22:00 GMT+01:00 stepharo <[hidden email]>:
Really interesting discussion. I like pragmas but this is interesting to see them challenged.

Thanks. It's a pleasure to discuss that way :)
 
Yes, but there end up being lots of naming conventions and they are non-obvious.  Whereas pragmas, because they are in-your-face in the methods in question, don't need conventions. They just need documenting ;-).
Thierry I'm skeptical that multiple protocol will save the problem because you will rely on coding conventions.

Pragma as well: just explain the conventions behind the gtInspector pragmas, for example.

But give me multiple protocols and I'll show you the same conventions rewritten in less lines (and a slightly more efficient code).
 
And pragma is a clever tagging.

Then maybe we should remove protocols and replace them with pragmas :)

Thierry
 

Stef








--
best,
Eliot

Reply | Threaded
Open this post in threaded view
|

Re: ||

Thierry Goubier
In reply to this post by Eliot Miranda-2


2015-02-07 20:48 GMT+01:00 Eliot Miranda <[hidden email]>:


Array literals are not executable.  They are literals.  They need an interpreter to add semantics.  This is one of the reasons why Spec is poor.  Pragmas are Message instances.  They respond to sendTo:/sentTo:.  STON is not executable, it needs an interpreter.

The STON thing was a joke on the tagging use of pragmas :)
 

There are other ways to add metadata to methods. Without tagging.

Haven't we discussed that?  Putting metadata off to the side introduces a bookkeeping problem.  It is a bad idea.

And pragmas only partially address that.

Partially?  It completely solves the issue of keeping metadata associated with a method.

It solve the issue of associating a limited form of metadata (one or two pragmas), with a few drawbacks (see below).
 

Imagine that Sista works, that it has dozens of tuning points for a method (int, no recurse, vect, is a reduce, openCL, thread-safe, hot point, this loop should be enrolled) do you imagine writing all that into the method to guide Sista with pragmas? You'll end up in exactly the same situation as OpenMP 4, where it is possible to write programs with more #pragma lines than C/C++ code.

One doesn't need a line per option.  One can use... literal arrays
    someImportantMethod        <sistaTuningHints: #(threadSafe unroll)>
but for Sista we imagine very few tuning options, perhaps only one, which is to say to the optimizer optimize this method even if it doesn't show up as a hot spot.  Sista is /not/ going to look like gcc.

Hum, that's sad. I wanted to try a few ideas along the ones I see in the HPC projects I'm on: specialisation, vectorisation, accelerator off-loading :(
 

 
The method with the menu pragma is named "worldMenuCommand" ...

I don't see examples of this in the pharo 4 image I have to hand.  What's the full selector?

Search for menu pragmas with the finder; the first two in Pharo30 are:

RecentMessageList>>recentMessageListMenuOn:
ScriptLoader30>>menuCommandOn:

(I just made the worldMenuCommand up :))

The tag is<worldMenu>, so it is strictly descriptive.
 
 
The method with the gtInspector pragma is named "gtInspectorPresentation..."

This one is ok.  The pragma both says the method is a pane in a glamour inspector, and says what the order is relative to others.  One thing that's broken is that the finder doesn't find any senders.  Another thing is that the pragma doesn't do anything.  If the Glamour inspector added panes to itself by using sentTo: to evaluate the pragma then when you did "implementors" you'd find the builder.

Ok. We're starting to get somewhere, with a better idea of what the semantic of pragmas should be.

And closer to what I said earlier: make pragmas executed at compile time.
 

So those examples are not taking full advantage.  In VW they're more interesting, e.g. 
searchForStringInSource
"Spawn a Browser on all methods which contain a specified string."

<menuItem: #(#MethodsWithPhraseDot #menus 'Methods with &Phrase...')
nameKey: nil
menu: #(#listMenu #browse) 
position: 21.03 >
...

In a way, I like this usage: it's clear, it will be executed.

In another way, yuck :( You're doing an OpenMP 4 kind of pragma (writing programs in the pragma syntax), forcing us to program in a pure literal dialect of smalltalk :(
 

which says which sub menu it is in (listMenu browse), where it is relative to other entries (21.03), what its hot key is (P). And MenuAutomaticGeneraotr implements the pragma (which shows up though the "implementors" menu on the menu pragma method):
menuItem: label nameKey: key menu: menuIDs position: position "If the method is to be inserted into our menu, create a MenuItem, otherwise answer nil." | realLabel | menuIDs first = menuName ifFalse: [^nil]. realLabel := self decodeLabel: label. ^Array with: ((MenuItem labeled: realLabel) nameKey: key) with: (menuIDs copyFrom: 2 to: menuIDs size) with: position


Additionally, as I told you before: the pragma semantic isn't in the method... It's somewhere else in the system and senders of that pragma doesn't get it.

I know that very well.  If things are done right, that the finder will find pragmas via "senders", and if the designer has chosen to implement the pragma in some processing object, then the link is made.  But I disagree that the semantic is entirely elsewhere in the system.  The /implementation/ is elsewhere in the system.  The semantic is in the pragma, in exactly the same way as a message specifies an operation to be performed and a method specifies an implementation, because... pragmas are messages.

But they can (and often are) used in a strictly descriptive way because they do not carry any clear semantic in Smalltalk itself.
 


Just have a look at OmniBrowser and tell me that you don't understand where the menu commands are :)

I don't want to criticise OmniBrowser, but if pragmas are used in the pattern above those relationships become clear.

You can't write full command objects the way you describe (with a single method and pragmas) because: command objects can inherit, they can have mutiple aspects (menu item, shortcut in window, key in menu, activation conditions). Pragmas are a solution if your commands are simple (lightweight command objects) and pragmas can't inherit if they are complex (nor can they use utility methods or complex processing, since they are literal messages).

Thanks for all the explanations, this was enlightening :) I'll probably have a look at how I use pragmas in AltBrowser command objects; now those are:

clipboardCommands
    <textAreaCommand>
    ^ #(#AltCutTextCommand #AltCopyTextCommand #AltPasteTextCommand #AltSelectAllTextCommand)

and, with your suggestions, it would become:

clipboardCommands
    <textAreaCommands: #(#AltCutTextCommand #AltCopyTextCommand #AltPasteTextCommand #AltSelectAllTextCommand)>

But I stay as strongly against them as before (probably even more: I didn't understand fully how nasty(*) considering them executable would be). I want a better solution :)

Happy to disagree :)

Thierry

(*) i.e. similar to C pragmas
1234