Compiler examples? comments?

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

Compiler examples? comments?

stepharo
Hi

The class comment of the compiler is not useful.

The compiler accepts Smalltalk source code and compiles it with respect
to a given class. The user of the compiler supplies a context so that
temporary variables are accessible during compilation. If there is an
error, a requestor (usually a kind of StringHolderController) is sent
the message notify:at:in: so that the error message can be displayed. If
there is no error, then the result of compilation is a MethodNode, which
is the root of a parse tree whose nodes are kinds of ParseNodes. The
parse tree can be sent messages to (1) generate code for a
CompiledMethod (this is done for compiling methods or evaluating
expressions); (2) pretty-print the code (for formatting); or (3) produce
a map from object code back to source code (used by debugger
program-counter selection). See also Parser, Encoder, ParseNode.


if I do not know how to invoke the compiler then I still have no clue.
Of course one may think that I'm too stupid to learn from the system.

so I tried

Compiler new
     class: ATActor;
     parse: 'foo ^ 23';
     compile

does not work.
No method comment!
Great. The system just tells me to stay away
ah yes there is

compile: textOrStream in: aClass classified: aCategory notifying:
aRequestor ifFail: failBlock
     "Answer a MethodNode for the argument, textOrStream. If the
     MethodNode can not be created, notify the argument, aRequestor; if
     aRequestor is nil, evaluate failBlock instead. The MethodNode is
the root
     of a parse tree. It can be told to generate a CompiledMethod to be
     installed in the method dictionary of the argument, aClass."

but in the public-old.

Why do we think that documenting is not worth?
Why don't we believe in comments?
Why don't we believe in examples?

Seriously when I learned smalltalk in VW every class had a real comment
and method too.

Stef


Reply | Threaded
Open this post in threaded view
|

Re: Compiler examples? comments?

Marcus Denker-4
Yes, the comments are bad.

I have a  TODO entry since ages to improve it, but there was always something more important to be done.

I will put it on higher priority.

        Marcus

> On 27 Jan 2016, at 18:52, stepharo <[hidden email]> wrote:
>
> Hi
>
> The class comment of the compiler is not useful.
>
> The compiler accepts Smalltalk source code and compiles it with respect to a given class. The user of the compiler supplies a context so that temporary variables are accessible during compilation. If there is an error, a requestor (usually a kind of StringHolderController) is sent the message notify:at:in: so that the error message can be displayed. If there is no error, then the result of compilation is a MethodNode, which is the root of a parse tree whose nodes are kinds of ParseNodes. The parse tree can be sent messages to (1) generate code for a CompiledMethod (this is done for compiling methods or evaluating expressions); (2) pretty-print the code (for formatting); or (3) produce a map from object code back to source code (used by debugger program-counter selection). See also Parser, Encoder, ParseNode.
>
>
> if I do not know how to invoke the compiler then I still have no clue.
> Of course one may think that I'm too stupid to learn from the system.
>
> so I tried
>
> Compiler new
>    class: ATActor;
>    parse: 'foo ^ 23';
>    compile
>
> does not work.
> No method comment!
> Great. The system just tells me to stay away
> ah yes there is
>
> compile: textOrStream in: aClass classified: aCategory notifying: aRequestor ifFail: failBlock
>    "Answer a MethodNode for the argument, textOrStream. If the
>    MethodNode can not be created, notify the argument, aRequestor; if
>    aRequestor is nil, evaluate failBlock instead. The MethodNode is the root
>    of a parse tree. It can be told to generate a CompiledMethod to be
>    installed in the method dictionary of the argument, aClass."
>
> but in the public-old.
>
> Why do we think that documenting is not worth?
> Why don't we believe in comments?
> Why don't we believe in examples?
>
> Seriously when I learned smalltalk in VW every class had a real comment and method too.
>
> Stef
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Compiler examples? comments?

stepharo
Thanks.
And the methods too.
Comments are ***IMPORTANT*** they are the first contact with our system.

Stef

Le 27/1/16 19:05, Marcus Denker a écrit :

> Yes, the comments are bad.
>
> I have a  TODO entry since ages to improve it, but there was always something more important to be done.
>
> I will put it on higher priority.
>
> Marcus
>
>> On 27 Jan 2016, at 18:52, stepharo <[hidden email]> wrote:
>>
>> Hi
>>
>> The class comment of the compiler is not useful.
>>
>> The compiler accepts Smalltalk source code and compiles it with respect to a given class. The user of the compiler supplies a context so that temporary variables are accessible during compilation. If there is an error, a requestor (usually a kind of StringHolderController) is sent the message notify:at:in: so that the error message can be displayed. If there is no error, then the result of compilation is a MethodNode, which is the root of a parse tree whose nodes are kinds of ParseNodes. The parse tree can be sent messages to (1) generate code for a CompiledMethod (this is done for compiling methods or evaluating expressions); (2) pretty-print the code (for formatting); or (3) produce a map from object code back to source code (used by debugger program-counter selection). See also Parser, Encoder, ParseNode.
>>
>>
>> if I do not know how to invoke the compiler then I still have no clue.
>> Of course one may think that I'm too stupid to learn from the system.
>>
>> so I tried
>>
>> Compiler new
>>     class: ATActor;
>>     parse: 'foo ^ 23';
>>     compile
>>
>> does not work.
>> No method comment!
>> Great. The system just tells me to stay away
>> ah yes there is
>>
>> compile: textOrStream in: aClass classified: aCategory notifying: aRequestor ifFail: failBlock
>>     "Answer a MethodNode for the argument, textOrStream. If the
>>     MethodNode can not be created, notify the argument, aRequestor; if
>>     aRequestor is nil, evaluate failBlock instead. The MethodNode is the root
>>     of a parse tree. It can be told to generate a CompiledMethod to be
>>     installed in the method dictionary of the argument, aClass."
>>
>> but in the public-old.
>>
>> Why do we think that documenting is not worth?
>> Why don't we believe in comments?
>> Why don't we believe in examples?
>>
>> Seriously when I learned smalltalk in VW every class had a real comment and method too.
>>
>> Stef
>>
>>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Compiler examples? comments?

Ben Coman
In reply to this post by stepharo
On Thu, Jan 28, 2016 at 1:52 AM, stepharo <[hidden email]> wrote:

> Hi
>
> The class comment of the compiler is not useful.
>
> The compiler accepts Smalltalk source code and compiles it with respect to a
> given class. The user of the compiler supplies a context so that temporary
> variables are accessible during compilation. If there is an error, a
> requestor (usually a kind of StringHolderController) is sent the message
> notify:at:in: so that the error message can be displayed. If there is no
> error, then the result of compilation is a MethodNode, which is the root of
> a parse tree whose nodes are kinds of ParseNodes. The parse tree can be sent
> messages to (1) generate code for a CompiledMethod (this is done for
> compiling methods or evaluating expressions); (2) pretty-print the code (for
> formatting); or (3) produce a map from object code back to source code (used
> by debugger program-counter selection). See also Parser, Encoder, ParseNode.
>
>
> if I do not know how to invoke the compiler then I still have no clue.
> Of course one may think that I'm too stupid to learn from the system.
>
> so I tried
>
> Compiler new
>     class: ATActor;
>     parse: 'foo ^ 23';
>     compile

Wouldn't that be OpalCompiler?

btw, do we want to rename Compiler to OldCompiler or 2015Compiler
before unloading - so it doesn't clash if it ever needs to be loaded
back for some emergency reason,
and also have a global variable holding the current compiler, or a
singleton class as a facade to the current compiler, thus perhaps
making the API more explicit?

cheers -ben