musing around with the compiler

Boris Gaertner Boris.Gaertner at gmx.net
Thu Feb 17 17:34:41 UTC 2005


 "stéphane ducasse" <ducasse at iam.unibe.ch> wrote:

> For the people interested in the solution: here is what I learned.
> I was used to the compiler of  VW and the one of squeak is a shock:
> menu built in parser, dependency from the parser to the UI, missing
> exception,
> strange logic: a beast :)

> So for my problem I added an OutOfScopeNotification signal but this is
> bad since this signal
> will only be invoked in none interactive mode.

> So I think that getting the new compiler in is really important.
Is it available on SqueakMap or elsewhere in the Squeak world?

> Encoder>>undeclared: name

> | sym |
> OutOfScopeNotification signal.
> requestor interactive ifTrue: [
> requestor requestor == #error: ifTrue: [requestor error:
> 'Undeclared'].
> ^ self notify: 'Undeclared'].
> Transcript show: ' (' , name , ' is Undeclared) '.
> sym := name asSymbol.
> Undeclared at: sym put: nil.
> ^self global: (Undeclared associationAt: sym) name: sym

Yes, you have identified the dark spot in that compiler.
This is very old code and it was never really upgraded to
exception handling. Have you noticed that the message
#requestor has no implementors in our newer images?  :-(

As you mentioned a new compiler, I do not feel myself
motivated to fix the old one - I would rather wish to test
and perhaps to review the new one.

Nevertheless, I want to add these remarks:

Our current code maintains a distinction between interactive
and non-interactive use of the compiler. A use is considered
an interactive one when you provide a ParagraphEditor as
receiver of possible notifications. Anything else is considered
a non-interactive use.

I think that this is not the complete image: In fact we know
about three different use cases:

1. 'File In':
During file in of code we write a message into the Transcript
and continue. This is an appropriate approach as it allows us
to detect a lot of errors at a time.

2. 'Interactive':
We have a notification receiver that is required to understand
the protocol of a ParagraphEditor. The notification receiver is
expected to display a piece of text. The parser (yes, regrettably
the parser!) displays a menu and processes the user's response.
The menu offers some proposals to fix a bug.

3. 'Direct call of the compiler'
This is what you did. For 'direct compiler call' you expect
to get an exception when things went wrong.

Currently the use cases 'File In' and 'Direct Call' are
both considered non-interactive uses of the compiler.


When we incorporate exception handling into the compiler,
we can say that the use cases have the responsibility to
provide appropriate exception handlers. The required
handlers are:

Use case 'File In':
Handler to write a message into the Transcript and to resume
parsing.

Use case 'Interactive'
Handler to highlight a portion of text, to display a menu
and to process the user's response.

Use case 'Direct compiler call':
No handlers required; Exceptions will be handled by the
caller or will show up in a notifier.

Is all this done in the new compiler or should we review
it once again?

Greetings, Boris

On 17 févr. 05, at 15:02, stéphane ducasse wrote:

> Hi
>
> I would like to check whether certain string are regular Smalltalk
> expressions (without evaluating them)
> So I played with the compiler and its lack of consistent exceptions.
> Anyway.
>
> Compiler new compile: 'zorkgloubibolga123456789 ', 'go' in: Bot
> notifying: nil ifFail: [nil]
> returns
>  zorkgloubibolga123456789
>
> go
> while I would like to be able to get an syntaxErrorNotification or
> OutOfScopeNotification since go is not an instance variable of class
> Bot.
>
>
> I tried
>
> [Compiler new compile: 'zorkgloubibolga123456789 ', 'go: 120' in: Bot
> notifying: nil ifFail: [nil]]
> on: SyntaxErrorNotification
> do: [ Beeper beep]
> and there I get an exception which is good for me.
>
>
>
> Does anybody has an idea how I can get an exception on the following
> case.
>
> [Compiler new compile: 'zorkgloubibolga123456789 ', 'go' in: Bot
> notifying: nil ifFail: [nil]]
> on: OutOfScopeNotification
> do: [ Beeper beep]
>
>





More information about the Squeak-dev mailing list