|
Posted by ImOk on 07/29/06 19:52
Richard Levasseur wrote:
> ImOk wrote:
> > Richard Levasseur wrote:
> > > ImOk wrote:
> > > > Smalltalk is the only language I know that was designed around case
> > > > sensitivity being used correctly and with a purpose. If you study their
> > > > system (and it's not complicated) you can write better code in all the
> > > > other languages.
> > > >
> > >
> > > I'm not familar with Small talk (though i always hear great things
> > > about it), but how does the case of identifiers affect things?
> >
> > It's 'Smalltalk' one word and lower case t :)
> >
> > The idea is that if you write the code in proper English you achieve a
> > couple of things:
> >
> > 1) The only necessary comments are the description at the top of a
> > method. Your English is self documenting the code.
> >
> > 2) Very short methods. If a method is longer than 1/2 of a screen this
> > means you cannot visually see your logicall without jumping up and
> > down. The language doesnt even have a case statement and the
> > ifTrue:ifFalse: is actually a method similar to inline ifs we have in
> > PHP.
> >
> > 3) You can write what could take you 5 lines of code on one line. You
> > just read left to right including the math (there is no operator
> > precedence).
> >
> > So it was necessary to have standards including case sensitivity to
> > make the coding concise.
>
> Not sure if that answers my question.
>
> >From your original post i got the impression that, depending on the
> case of identifiers, Smalltalk would enforce that convention.
> ie:
> MYCONST => a global or constant value
> MyClass => required to be a class declaration
> myIdentifier => required to be a variable or method
>
> Which could potentially be a nice feature in a language. Or it could
> be really annoying.
It does enforce some things. A class and globals must start with an
uppercase letter.
All methods and local variables start with lower case letters.
Here is a class definition for the class File (by the way most of
Smalltalk is written in itself. So you actually see source code when
you click on a method or class in the browser)
Object subclass: #File
instanceVariableNames: 'handle spec flags shareFlags'
classVariableNames: 'CheckModes NoCheckModes OpenFlagsMask ShareModes'
poolDictionaries: 'CRTConstants Win32Constants Win32Errors'
classInstanceVariableNames: ''.
Object is the top class. Every class is a subclass of it. As soon as
you type the above command and click accept, the class becomes active
in the image. Here is an example of how you would use a method to open
a file
fileHandle:=File new.
fileHandle open: 'test.txt' mode: #create check: true: share:
#readWrite.
This would be similar to:
fileHandle= new File();
fileHandle->open('test.txt','create',true,,'rw');
In general, I am trying to point out that they have a very precise
standard with definitions. Part of it is enforcable, and part of it is
a discipline. You can look at code from another Smalltalker and
immediately recognize what is going on.
If clients didnt care what I used for development, I would be using
Smalltalk for everything. Unfortunately, it got buried under the Java
hype and mega corporations and FUD.
Navigation:
[Reply to this message]
|