Simple Program Won't Run

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

Simple Program Won't Run

highbeg
Hi Everybody,

Obviously what programming skills I have are other than Oops :-)

What Oops rule(s) does the following program, autoRun,st, break? Why is MyA
written as #MyA in the error message? Why doesn't the compiler understand
MyA? It's defined in the immediately preceding line.

Gary Highberger

cat autoRun.st
MyA := Array new: 10
MyA at: 1 put: 'one'
3 printNl
'hello world' printNl

$ gst autoRun.st
Object: 10 error: did not understand #MyA
MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
SmallInteger(Object)>>doesNotUnderstand: #MyA (SysExcept.st:1448)
UndefinedObject>>executeStatements (autoRun.st:1)
3
'hello world'
$
Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

Jan Vrany


On Fri, 2021-01-15 at 12:38 -0500, Gary Highberger wrote:

> Hi Everybody,
>
> Obviously what programming skills I have are other than Oops :-)
>
> What Oops rule(s) does the following program, autoRun,st, break? Why
> is MyA
> written as #MyA in the error message? Why doesn't the compiler
> understand
> MyA? It's defined in the immediately preceding line.
>
> Gary Highberger
>
> cat autoRun.st
> MyA := Array new: 10
> MyA at: 1 put: 'one'
> 3 printNl
> 'hello world' printNl
>


You need to separate statements by dot, i.e.,

MyA := Array new: 10. "<-- see the dot"
MyA at: 1 put: 'one'. "<-- see the dot"
3 printNl. "<-- see the dot"
'hello world' printNl . "<-- see the dot"

Think of dot as a dot at the end of sentence or
as a ; in most of other languages.

HTH, Jan



> $ gst autoRun.st
> Object: 10 error: did not understand #MyA
> MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
> SmallInteger(Object)>>doesNotUnderstand: #MyA (SysExcept.st:1448)
> UndefinedObject>>executeStatements (autoRun.st:1)
> 3
> 'hello world'
> $



Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

Ludovic-2
In reply to this post by highbeg
Le 15/01/2021 à 18:38, Gary Highberger a écrit :

> Hi Everybody,
>
> Obviously what programming skills I have are other than Oops :-)
>
> What Oops rule(s) does the following program, autoRun,st, break? Why is MyA
> written as #MyA in the error message? Why doesn't the compiler understand
> MyA? It's defined in the immediately preceding line.
>
> Gary Highberger
>
> cat autoRun.st
> MyA := Array new: 10
> MyA at: 1 put: 'one'
> 3 printNl
> 'hello world' printNl

Hi Gary,

you forgot the end of statement marker :  the dot (".").

example:

   myArray := Array new: 10.

And an advice, you should start your variables with a lower case letter.

--
Ludovic


Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

highbeg
In reply to this post by highbeg
Hi Help-Smalltalk,

I put periods after each line and then the Smalltalk program ran just fine.
Is there a way to avoid having to put periods after each line? What end of
statement characters besides period does Smalltalk expect? Maybe my editor
can be reconfigured accordingly.

Thanks everyone,
Gary


On Fri, Jan 15, 2021, 12:38 PM Gary Highberger <[hidden email]>
wrote:

> Hi Everybody,
>
> Obviously what programming skills I have are other than Oops :-)
>
> What Oops rule(s) does the following program, autoRun,st, break? Why is
> MyA written as #MyA in the error message? Why doesn't the compiler
> understand MyA? It's defined in the immediately preceding line.
>
> Gary Highberger
>
> cat autoRun.st
> MyA := Array new: 10
> MyA at: 1 put: 'one'
> 3 printNl
> 'hello world' printNl
>
> $ gst autoRun.st
> Object: 10 error: did not understand #MyA
> MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
> SmallInteger(Object)>>doesNotUnderstand: #MyA (SysExcept.st:1448)
> UndefinedObject>>executeStatements (autoRun.st:1)
> 3
> 'hello world'
> $
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

Jan Vrany



On Fri, 2021-01-15 at 22:56 -0500, Gary Highberger wrote:

> Hi Help-Smalltalk,
>
> I put periods after each line and then the Smalltalk program ran just
> fine.
> Is there a way to avoid having to put periods after each line? What
> end of
> statement characters besides period does Smalltalk expect? Maybe my
> editor
> can be reconfigured accordingly.
>
. (dot) is (the only) statement separator, i.e, two statements must be
separated by . (dot). Otherwise, you get either syntax error or DNU.

HTH, Jan

> Thanks everyone,
> Gary
>
>
> On Fri, Jan 15, 2021, 12:38 PM Gary Highberger <
> [hidden email]>
> wrote:
>
> > Hi Everybody,
> >
> > Obviously what programming skills I have are other than Oops :-)
> >
> > What Oops rule(s) does the following program, autoRun,st, break?
> > Why is
> > MyA written as #MyA in the error message? Why doesn't the compiler
> > understand MyA? It's defined in the immediately preceding line.
> >
> > Gary Highberger
> >
> > cat autoRun.st
> > MyA := Array new: 10
> > MyA at: 1 put: 'one'
> > 3 printNl
> > 'hello world' printNl
> >
> > $ gst autoRun.st
> > Object: 10 error: did not understand #MyA
> > MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
> > SmallInteger(Object)>>doesNotUnderstand: #MyA (SysExcept.st:1448)
> > UndefinedObject>>executeStatements (autoRun.st:1)
> > 3
> > 'hello world'
> > $
> >
> >



Reply | Threaded
Open this post in threaded view
|

RE: Simple Program Won't Run

mbratch
In reply to this post by highbeg

HI Gary

 

Perhaps you could explain why the periods pose a problem?

In C or Pascal, for example, a semicolon is mandatory as a statement separator.

What editor are you using and what is the desired intent of the reconfiguration?

 

Sent from Mail for Windows 10

 

From: [hidden email]
Sent: Friday, January 15, 2021 10:56 PM
To: [hidden email]
Subject: Re: Simple Program Won't Run

 

Hi Help-Smalltalk,

 

I put periods after each line and then the Smalltalk program ran just fine.

Is there a way to avoid having to put periods after each line? What end of

statement characters besides period does Smalltalk expect? Maybe my editor

can be reconfigured accordingly.

 

Thanks everyone,

Gary

 

 

On Fri, Jan 15, 2021, 12:38 PM Gary Highberger <[hidden email]>

wrote:

 

> Hi Everybody,

> 

> Obviously what programming skills I have are other than Oops :-)

> 

> What Oops rule(s) does the following program, autoRun,st, break? Why is

> MyA written as #MyA in the error message? Why doesn't the compiler

> understand MyA? It's defined in the immediately preceding line.

> 

> Gary Highberger

> 

> cat autoRun.st

> MyA := Array new: 10

> MyA at: 1 put: 'one'

> 3 printNl

> 'hello world' printNl

> 

> $ gst autoRun.st

> Object: 10 error: did not understand #MyA

> MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)

> SmallInteger(Object)>>doesNotUnderstand: #MyA (SysExcept.st:1448)

> UndefinedObject>>executeStatements (autoRun.st:1)

> 3

> 'hello world'

> $

> 

> 

 

Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

Gnu mailing list
In reply to this post by highbeg

Gary Highberger writes:

> Hi Help-Smalltalk,
>
> I put periods after each line and then the Smalltalk program ran just fine.
> Is there a way to avoid having to put periods after each line? What end of
> statement characters besides period does Smalltalk expect? Maybe my editor
> can be reconfigured accordingly.

gst's REPL can live without the period, because it is evaluating
statements one line at a time. Consider this a convenience feature that
is not 100% conforming to spec.
In a fileIn you have to have the period other wise it has no way to tell
where statement is ended (which can span multiple lines)

>
> Thanks everyone,
> Gary
>
>
> On Fri, Jan 15, 2021, 12:38 PM Gary Highberger <[hidden email]>
> wrote:
>
>> Hi Everybody,
>>
>> Obviously what programming skills I have are other than Oops :-)
>>
>> What Oops rule(s) does the following program, autoRun,st, break? Why is
>> MyA written as #MyA in the error message? Why doesn't the compiler
>> understand MyA? It's defined in the immediately preceding line.
>>
>> Gary Highberger
>>
>> cat autoRun.st
>> MyA := Array new: 10
>> MyA at: 1 put: 'one'
>> 3 printNl
>> 'hello world' printNl
>>
>> $ gst autoRun.st
>> Object: 10 error: did not understand #MyA
>> MessageNotUnderstood(Exception)>>signal (ExcHandling.st:254)
>> SmallInteger(Object)>>doesNotUnderstand: #MyA (SysExcept.st:1448)
>> UndefinedObject>>executeStatements (autoRun.st:1)
>> 3
>> 'hello world'
>> $
>>
>>


Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

bill-auger
it does conform to the spec though - the REPL syntax is exactly
the same as a static file - the dot is not a statement
terminator as with C-like languages - it is a statement
separator, which means it is optional, where there is only one
single statement - the same is true in a method definition - it
is the reason why you rarely see a dot after the final LOC of a
method definition - you will find that you can enter multiple
statements on a single line in the REPL, just the same as you
could in a static file; but they must be delimited by the
separator char

st> 2 print . 3 print
22
33

Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

stes

I'm not sure that the Blue book has something like REPL
(Read-Eval-Print-Loop) and LOC (Lines of Code ?).

GNU smalltalk does a fine job of implementing some of the concepts of the interactive Smalltalk-80,
system, towards the world of line-oriented "REPL" read-eval-print-loop.

It also does this while retaining a good look-and-feel of the Smalltalk-80 language,
but GNU smalltalk on the other hand is not as interactive as the other Smalltalk systems.

But Smalltalk-80 as a graphical "system" and interactive "system",
in the "interactive" system it is about "selecting" the statements that you want to evaluate.

For example you select statements in the "Workspace" and then the output can be in a "Transcript",
after you evaluate them by using the menu "Do it" or keyboard equivalent for "do-it".

As far as I can see in the "Blue book" (ST-80 Language and its Implementation),
it says:

"A method is made up of a message pattern and a sequence of expressions
separated by periods." (page 70)

But on page 73 it talks about the "interactive Smalltalk-80" system and writes,

"The programmer interactively selects all five lines - - the declaration
and the expressions - - and requests evaluation. "

And indeed on page 73 for interactively selected expressions: "The expressions are separated by periods, as in the syntax of a method."

Also for Blocks on page 53:
" A block represents a deferred sequence of actions.
A block expression consists of a sequence of expressions separated by
periods and delimited by square brackets. "


So basically GNU Smalltalk is following as well as possible those rules,
in the context of a line-oriented UNIX style read-eval-print-loop.

David Stes


----- Op 16 jan 2021 om 22:31 schreef bill-auger [hidden email]:

> it does conform to the spec though - the REPL syntax is exactly
> the same as a static file - the dot is not a statement
> terminator as with C-like languages - it is a statement
> separator, which means it is optional, where there is only one
> single statement - the same is true in a method definition - it
> is the reason why you rarely see a dot after the final LOC of a
> method definition - you will find that you can enter multiple
> statements on a single line in the REPL, just the same as you
> could in a static file; but they must be delimited by the
> separator char
>
> st> 2 print . 3 print
> 22
> 33

Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

bill-auger
for all intents and purposes, entering a line feed int the REPL
is equivalent to "print it"

FWIW, GNU smalltalk's somewhat radical divergences from ST80,
are actually the natural evolution of the system, given that the
smalltalk machines, which were originally conceived,, do not
actually exist - the course of history demoted smalltalk to an
application, running on a VM, running on foreign hardware, and
mostly isolated from the real machine or its real operating
system - only recently, have other smalltalks such as pharo, put
any emphasis on interoperability with heterogeneous
(non-smalltalk) systems, outside its closed world - they are now
working on a "headless" pharo, which can be configured
(or "booted") via init scripts and controlled via an API from
another system - in that respect, gnu-smalltalk was far "ahead
of the curve" (a characteristic, very much in the smalltalk
tradition)

so, the blue book specifications must be viewed WRT the
historical context - at that time, the GUI was something of a
novelty, which set smalltalk apart from all other general-purpose
systems - the smalltalk visionaries were not only designing a
programming language, or an IDE application; they were inventing
the entire concept of "the GUI" - today GUIs are ubiquitous - if
that book were written today, they probably would have omitted
all of the GUI-specific operations, deferring that concern
(presentation/HCI), arbitrarily to the whims of implementors

for example, no one today would specify that some operation
_must_ be done, using "middle-mouse-button" or "CTRL-p" - it is
easy to imagine, that if the original smalltalk designers had
any inkling, that it would actually be but one among many
development tools, running on top of a UNIX system, they
probably would have specified a command-line interface, and
interoperability with system libs, to extend the capabilities of
the otherwise reclusive GUI world

Reply | Threaded
Open this post in threaded view
|

Re: Simple Program Won't Run

Gnu mailing list
In reply to this post by bill-auger

bill-auger writes:

> it does conform to the spec though - the REPL syntax is exactly
> the same as a static file - the dot is not a statement
> terminator as with C-like languages - it is a statement
> separator, which means it is optional, where there is only one
> single statement

Classic smalltalk has both seperator "." and terminator "!".
GST 3.0 syntax tries to do away the terminator "!" by using [] around
method bodies. The behavior of the gst REPL is the compromise
between the two. I like that because it is pactical, unlike eg. erlang
REPL that always demands a terminator. However, it is not the same with
a fileIn syntax; you cannot be the same with 2 distinct syntaxs at the
same time.

Derek