Example where static variables are unavoidable... does it exist?

J

Jezuch

U¿ytkownik Randall R Schulz napisa³:
Blank lines? Code divided into "paragraphs?"

I surely thought I was the only one.

Really? It is so obvious to me, and I *am* a (relative) newbie :)
 
W

Wojtek

U¿ytkownik Randall R Schulz napisa³:

Really? It is so obvious to me, and I *am* a (relative) newbie :)

Then you have seen the light :))

I have tried to convince many a prgorammer that proper code
formatting, in the long run, is better. They never seem to want to
make the effort early on. I have seen code like:

---------------
dosomthing();
doAnotherthing();

if ( test )
runCode();

runMoreCode();

go();
 
T

TGOS

Not at all, I'm objecting to your spreading your misconceptions as if they were
facts.

I'm spreading my opinion, like pretty much everyone else on Usenet.
Since when is Usenet about facts? ;-)
For instance, I can only assume that your assertion that "It uses space
as separator" is coming from the process I outlined above. Smalltalk uses
whitespace in *exactly* the same way as most other languages.

No, it doesn't!
It uses space as separator between objects and methods:

<object> <method-name>:<first-parameter>

e.g.

mySet := Set new !
mySet add:5 !
^
There is no other separator between "mySet" and "add" other than space.
Don't try to denial that, it's the truth. And different parameter are
separated by space, too. So worth enough that space is a bad separator,
no, twice the same separator is used to separate three completely
different kind of things:

<object> <mname-part1>:<1st-parameter> <mname-part2>:<2nd-parameter>

E.g.

myArray := Array new: 20 !
myArray at: 1 put: 99 !
^ ^
The separator between "MyArray" and "at" is *space*. And the separator
between the "at" parameter and the "put" is *space*.

Compare this to Java, where a "period" is used to separate between
object and method and where a "comma" is used to separate between
different parameters (and additionally brackets, to show where
parameters start and where they end, which is not marked at all in
Smalltalk):

Hashtable myHashtable = new Hashtable(20);
myHashtable.put("key", "value");
^ ^
The space after the comma is completely optional and only there to make
it more "human eye friendly" (as we are used to see a space after a
comma).
Another example:


This is ignorance speaking again. If you look at Smalltalk code in the
expected way then it is *absolutely* clear where methods (and classes) end.

!Account methodsFor: 'moving money'!
spend: amount
balance := balance - amount
!
deposit: amount
balance := balance + amount
! !

Remove indention and it'a almost unreadable. The "colon" separates
method name and parameters, but with an equal sign behind it, it assigns
a value to a variable (twice the same character, two completely
different meanings). Last line of method is usually not terminated
(inconsistency is the keyword for that! Either lines are to be
terminated, then all lines should or they are not, then no line should
be terminated). And using a "exclamation mark" as "begin" or "end" of
something is a very bad idea, because if you just see a single
exclamation mark, you can't tell whether it's the "start" of anything or
the end of anything (that's why Java uses brackets, round, squared or
curly ones).
The bits of code that you posted are in a format (called "file-out", or
"chunked") that is *not intended for humans to read*.

Interesting that this is the way how all Smalltalk tutorials teach
Smalltalk (by using something not indentended for humands to read) :p

I guess most Smalltalk developers spent too much programming time in
high level IDEs and have forgotten that sometimes programming means
writing a file with a text editor.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top