What's wrong with this script??

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

What's wrong with this script??

Rick Flower
This is my first gst script -- I've used VW quite a bit but just
don't see why this very basic code is not happy.. Ideas?  When I
run the script I get the following results (DNU on #retname)..
I guess I was spoiled by the GUI in Squeak and VW.. Perhaps I'm
missing some sort of formatting marks?  Is there an Eclipse plugin
for editing GST code?

Object: TestFile error: did not understand #retname
MessageNotUnderstood(Exception)>>signal (AnsiExcept.st:216)
TestFile class(Object)>>doesNotUnderstand: #retname (AnsiExcept.st:1556)
UndefinedObject>>executeStatements (rcslog2.st:42)


#!/usr/local/bin/gst -f

Object subclass: #TestFile
                instanceVariableNames: 'fname reports'
        classVariableNames: ''
        poolDictionaries: ''
        category: 'My-Scripting'!

 TestFile comment:
'This class represents a single controlled file which has a collection of
 reports associated with it.' !

!TestFile class methodsFor: 'instance creation'!
        new [ ^super new initialize ] !
!


!TestFile methodsFor: 'instance creation'!
        initialize
    fname    := String new.
    reports  := OrderedCollection new.
    Transcript show: 'TestFile created!'; cr. !
!
       
!TestFile methodsFor: 'accessing'!

setname: aName
        fname := aName.!
               
retname
        ^fname!
               
reports
        ^reports !
!

"main program starts here...
 Stuff.."
| aFile |

                aFile := TestFile new.
                Transcript show: aFile retname.


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Paolo Bonzini-2
On 02/25/2010 06:35 PM, Rick Flower wrote:
> new [ ^super new initialize ] !

No brackets when using old (bang) syntax, so this returns self.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Rick Flower
On Thu, 25 Feb 2010 19:12:17 +0100, Paolo Bonzini <[hidden email]> wrote:
> On 02/25/2010 06:35 PM, Rick Flower wrote:
>> new [ ^super new initialize ] !
>
> No brackets when using old (bang) syntax, so this returns self.
 
Thanks Paolo!  It was right under my eyes and I didn't even
see it.. Ugg!  If I want maximum compatibility with Squeak or
VW, is that the best format to use?  It seems close to the format
used by VW (for parcels?  I forget now).  Thanks for the quick
reply!


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Mehul Sanghvi-2
In reply to this post by Paolo Bonzini-2
Being new to Smalltalk, and learning it on and off when I get time
here and there,
what is "new" syntax if the "old" syntax is the "!" ?

On Thu, Feb 25, 2010 at 13:12, Paolo Bonzini <[hidden email]> wrote:

> On 02/25/2010 06:35 PM, Rick Flower wrote:
>>
>>        new [ ^super new initialize ] !
>
> No brackets when using old (bang) syntax, so this returns self.
>
> Paolo
>
>
> _______________________________________________
> help-smalltalk mailing list
> [hidden email]
> http://lists.gnu.org/mailman/listinfo/help-smalltalk
>



--
Mehul N. Sanghvi
email: [hidden email]
Joan Crawford  - "I, Joan Crawford, I believe in the dollar.
Everything I earn, I spend." -
http://www.brainyquote.com/quotes/authors/j/joan_crawford.html


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Paolo Bonzini-2
In reply to this post by Rick Flower
On 02/25/2010 07:19 PM, Rick Flower wrote:
> On Thu, 25 Feb 2010 19:12:17 +0100, Paolo Bonzini<[hidden email]>  wrote:
>> On 02/25/2010 06:35 PM, Rick Flower wrote:
>>> new [ ^super new initialize ] !
>>
>> No brackets when using old (bang) syntax, so this returns self.
>
> Thanks Paolo!  It was right under my eyes and I didn't even
> see it.. Ugg!  If I want maximum compatibility with Squeak or
> VW, is that the best format to use?

gst-convert can convert to Squeak's format.  It cannot convert to VW
format yet, but the gst2 output format of gst-convert is quite close.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Paolo Bonzini-2
In reply to this post by Mehul Sanghvi-2
On 02/25/2010 08:03 PM, Mehul Sanghvi wrote:
> Being new to Smalltalk, and learning it on and off when I get time
> here and there, what is "new" syntax if the "old" syntax is the "!"
> ?

New syntax is like this:


Object subclass: Base64 [
     Base64 class >> encode: aString [
         | i j outSize c1 c2 c3 out b64string chars |
         chars := ##('ABCDEFGHIJKLMNOPQRSTUVWXYZ',
                     'abcdefghijklmnopqrstuvwxyz0123456789+/=').
         outSize := aString size // 3 * 4.
         (aString size \\ 3) = 0 ifFalse: [ outSize := outSize + 4 ].
         b64string := String new: outSize.

         i := 1.
         1 to: outSize by: 4 do: [ :j |
             c1 := aString valueAt: i ifAbsent: [0].
             c2 := aString valueAt: i+1 ifAbsent: [0].
             c3 := aString valueAt: i+2 ifAbsent: [0].

             out := c1 bitShift: -2.
             b64string at: j put: (chars at: out + 1).

             out := ((c1 bitAnd: 3) bitShift: 4) bitOr: (c2 bitShift: -4).
             b64string at: j+1 put: (chars at: out + 1).

             out := ((c2 bitAnd: 15) bitShift: 2) bitOr: (c3 bitShift: -6).
             b64string at: j+2 put: (chars at: out + 1).

             out := c3 bitAnd: 16r13F.
             b64string at: j+3 put: (chars at: out + 1).

             i := i + 3.
         ].

         b64string
             replaceFrom: outSize - (i - aString size) + 2
             to: outSize withObject: $=.

        ^b64string
    ]
]


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Mehul Sanghvi-2
Thanks Paolo.  So where/when/what version of ST  should new syntax be used ?

Is this a GST thing or a ST thing in general ?  I don't recall seeing
the old syntax
in the "Smalltalk, Objects, and Design' book, but then it could be
that I was not
paying too much attention.

I have seen it in the GST info pages, but that's the only place.


On Thu, Feb 25, 2010 at 14:56, Paolo Bonzini <[hidden email]> wrote:

> On 02/25/2010 08:03 PM, Mehul Sanghvi wrote:
>>
>> Being new to Smalltalk, and learning it on and off when I get time
>> here and there, what is "new" syntax if the "old" syntax is the "!"
>> ?
>
> New syntax is like this:
>
>
> Object subclass: Base64 [
>    Base64 class >> encode: aString [
>        | i j outSize c1 c2 c3 out b64string chars |
>        chars := ##('ABCDEFGHIJKLMNOPQRSTUVWXYZ',
>                    'abcdefghijklmnopqrstuvwxyz0123456789+/=').
>        outSize := aString size // 3 * 4.
>        (aString size \\ 3) = 0 ifFalse: [ outSize := outSize + 4 ].
>        b64string := String new: outSize.
>
>        i := 1.
>        1 to: outSize by: 4 do: [ :j |
>            c1 := aString valueAt: i ifAbsent: [0].
>            c2 := aString valueAt: i+1 ifAbsent: [0].
>            c3 := aString valueAt: i+2 ifAbsent: [0].
>
>            out := c1 bitShift: -2.
>            b64string at: j put: (chars at: out + 1).
>
>            out := ((c1 bitAnd: 3) bitShift: 4) bitOr: (c2 bitShift: -4).
>            b64string at: j+1 put: (chars at: out + 1).
>
>            out := ((c2 bitAnd: 15) bitShift: 2) bitOr: (c3 bitShift: -6).
>            b64string at: j+2 put: (chars at: out + 1).
>
>            out := c3 bitAnd: 16r13F.
>            b64string at: j+3 put: (chars at: out + 1).
>
>            i := i + 3.
>        ].
>
>        b64string
>            replaceFrom: outSize - (i - aString size) + 2
>            to: outSize withObject: $=.
>
>       ^b64string
>   ]
> ]
>



--
Mehul N. Sanghvi
email: [hidden email]
Samuel Goldwyn  - "I don't think anyone should write their
autobiography until after they're dead." -
http://www.brainyquote.com/quotes/authors/s/samuel_goldwyn.html


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Rick Flower
On Thu, 25 Feb 2010 18:13:43 -0500, Mehul Sanghvi
<[hidden email]>
wrote:
> Thanks Paolo.  So where/when/what version of ST  should new syntax be
used
> ?
>
> Is this a GST thing or a ST thing in general ?  I don't recall seeing
> the old syntax
> in the "Smalltalk, Objects, and Design' book, but then it could be
> that I was not
> paying too much attention.
>
> I have seen it in the GST info pages, but that's the only place.

I can't speak for what versions support which type (old,new) but I do know
that if you read the "computer programming using GNU smalltalk" book that
was released last year, they push the new style format (see page 61)..
I believe this is mostly GST specific for the most part.. I don't think
any
of the other ST players (Cincom, Pharoah, Squeak,etc) have one particular
standard they follow -- there are conversion tools to move between the
dialects..

HTH!



_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

ZuLuuuuuu
Rick Flower wrote
I can't speak for what versions support which type (old,new) but I do know
that if you read the "computer programming using GNU smalltalk" book that
was released last year, they push the new style format (see page 61)..
I believe this is mostly GST specific for the most part.. I don't think
any
of the other ST players (Cincom, Pharoah, Squeak,etc) have one particular
standard they follow -- there are conversion tools to move between the
dialects..
Actually, I didn't want to suggest one style over another when writing that chapter. I just wanted to teach the latest style (and, AFAIK, the recommended style by Paolo). There are a whole lot of discussions about this new syntax on archive of the mailing list which you can reach here:

http://n4.nabble.com/forum/Search.jtp?query=new+syntax&days=0&node=1290346

I am myself planning to go through the old messages to get a better understanding of the differences between the two syntax and to learn whether there are still any reasons to use the old syntax.
Canol Gökel
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Paolo Bonzini-2
On 02/26/2010 09:49 AM, ZuLuuuuuu wrote:
> I am myself planning to go through the old messages to get a better
> understanding of the differences between the two syntax and to learn whether
> there are still any reasons to use the old syntax.

There are none.  The last one was compatibility with other dialects, but
the compatibility was not 100% unlike what you get with gst-convert.

There are still some pieces using old-style syntax in the GNU Smalltalk
source, they're mostly there to provide coverage for the parsing code.

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk
Reply | Threaded
Open this post in threaded view
|

Re: What's wrong with this script??

Paolo Bonzini-2
In reply to this post by Mehul Sanghvi-2
On 02/26/2010 12:13 AM, Mehul Sanghvi wrote:
> Thanks Paolo.  So where/when/what version of ST  should new syntax be
> used ?

3.x is supporting the new syntax.  I don't think you want to use
anything earlier than 3.1 (one feature for all: the filesystem classes
were rewritten and are vastly more powerful as well as easier to use).

> Is this a GST thing or a ST thing in general ?  I don't recall
> seeing the old syntax in the "Smalltalk, Objects, and Design' book,
> but then it could be that I was not paying too much attention.

The old syntax is found in "Smalltalk: Bits of History, Words of Advice"
(available at http://stephane.ducasse.free.fr/FreeBooks.html).

Paolo


_______________________________________________
help-smalltalk mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/help-smalltalk