If blocks are objects why can't they be stored literally in arrays:

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

If blocks are objects why can't they be stored literally in arrays:

John Small
For example

    #( 1  2  [ ] )

Things get weird with:

    Array with: 1 with: 2 with: []


Reply | Threaded
Open this post in threaded view
|

Re: If blocks are objects why can't they be stored literally in arrays:

Peter Schuller
> For example
>
>     #( 1  2  [ ] )
>
> Things get weird with:
>
>     Array with: 1 with: 2 with: []

In Smalltalk/X the former seems to fail as a matter of syntax. I can
accept that.

The latter works fine. What was supposed to happen?

--
/ Peter Schuller, InfiDyne Technologies HB

PGP userID: 0xE9758B7D or 'Peter Schuller <[hidden email]>'
Key retrival: Send an E-Mail to [hidden email]
E-Mail: [hidden email] Web: http://www.scode.org



-----------== Posted via Newsfeeds.Com - Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Ulimited Fast Downloads - 19 Servers =-----


Reply | Threaded
Open this post in threaded view
|

Re: If blocks are objects why can't they be stored literally in arrays:

Costas
In reply to this post by John Small
On Wed, 19 Jun 2002 15:42:56 -0400, "John Small"
<[hidden email]> wrote:

>For example
>
>    #( 1  2  [ ] )

A block is not a literal. Only literals are allowed in a litreral
array.

>Things get weird with:
>    Array with: 1 with: 2 with: []

Nothing weird with the above in Dolphin. See test below.

ar:=Array with: 1 with: 2 with: [] with: [1+1].

(ar at: 3) value.  answers--> nil

(ar at: 4) value.  answers --> 2


This may look weird but its just the display.

ar at: 4.   answres --> ar:=Array with: 1 with: 2 with: [] with:
[1+1].

(ar at: 3) value.

(ar at: 4) value.

Costas


Reply | Threaded
Open this post in threaded view
|

Re: If blocks are objects why can't they be stored literally in arrays:

John Small
In reply to this post by Peter Schuller
Hi Pete,

Array with: 1 with: 2 with: []

in Dolphin 5  XP produces:

    #(1 2 Array with: 1 with: 2 with: [])

which looks like some kind of recursive mumbo jumbo because

    (Array with:1 with: 2 with: []) at: 3

yields itself:

    (Array with:1 with: 2 with: []) at: 3

I think the block closure is confused.

Any way I have abandon my design attempt at pseudo virtual function
(block) tables.

Thanks!

John

"Peter Schuller" <[hidden email]> wrote in message
news:[hidden email]...

> > For example
> >
> >     #( 1  2  [ ] )
> >
> > Things get weird with:
> >
> >     Array with: 1 with: 2 with: []
>
> In Smalltalk/X the former seems to fail as a matter of syntax. I can
> accept that.
>
> The latter works fine. What was supposed to happen?
>
> --
> / Peter Schuller, InfiDyne Technologies HB
>
> PGP userID: 0xE9758B7D or 'Peter Schuller <[hidden email]>'
> Key retrival: Send an E-Mail to [hidden email]
> E-Mail: [hidden email] Web: http://www.scode.org
>
>
>
> -----------== Posted via Newsfeeds.Com - Uncensored Usenet News
==----------
>    http://www.newsfeeds.com       The #1 Newsgroup Service in the World!
> -----= Over 100,000 Newsgroups - Ulimited Fast Downloads - 19 Servers
=-----


Reply | Threaded
Open this post in threaded view
|

Re: If blocks are objects why can't they be stored literally in arrays:

John Small
In reply to this post by Costas
I stand corrected.  Costas is right - thank you for this clarification!

John

"Costas" <[hidden email]> wrote in message
news:[hidden email]...

> On Wed, 19 Jun 2002 15:42:56 -0400, "John Small"
> <[hidden email]> wrote:
>
> >For example
> >
> >    #( 1  2  [ ] )
>
> A block is not a literal. Only literals are allowed in a litreral
> array.
>
> >Things get weird with:
> >    Array with: 1 with: 2 with: []
>
> Nothing weird with the above in Dolphin. See test below.
>
> ar:=Array with: 1 with: 2 with: [] with: [1+1].
>
> (ar at: 3) value.  answers--> nil
>
> (ar at: 4) value.  answers --> 2
>
>
> This may look weird but its just the display.
>
> ar at: 4.   answres --> ar:=Array with: 1 with: 2 with: [] with:
> [1+1].
>
> (ar at: 3) value.
>
> (ar at: 4) value.
>
> Costas
>


Reply | Threaded
Open this post in threaded view
|

Re: If blocks are objects why can't they be stored literally in arrays:

John Small
In reply to this post by John Small
I stand corrected.  Pete and Costas are right - thank you for this
clarification!

John

"John Small" <[hidden email]> wrote in message
news:[hidden email]...

> Hi Pete,
>
> Array with: 1 with: 2 with: []
>
> in Dolphin 5  XP produces:
>
>     #(1 2 Array with: 1 with: 2 with: [])
>
> which looks like some kind of recursive mumbo jumbo because
>
>     (Array with:1 with: 2 with: []) at: 3
>
> yields itself:
>
>     (Array with:1 with: 2 with: []) at: 3
>
> I think the block closure is confused.
>
> Any way I have abandon my design attempt at pseudo virtual function
> (block) tables.
>
> Thanks!
>
> John
>
> "Peter Schuller" <[hidden email]> wrote in message
> news:[hidden email]...
> > > For example
> > >
> > >     #( 1  2  [ ] )
> > >
> > > Things get weird with:
> > >
> > >     Array with: 1 with: 2 with: []
> >
> > In Smalltalk/X the former seems to fail as a matter of syntax. I can
> > accept that.
> >
> > The latter works fine. What was supposed to happen?
> >
> > --
> > / Peter Schuller, InfiDyne Technologies HB
> >
> > PGP userID: 0xE9758B7D or 'Peter Schuller <[hidden email]>'
> > Key retrival: Send an E-Mail to [hidden email]
> > E-Mail: [hidden email] Web: http://www.scode.org
> >
> >
> >
> > -----------== Posted via Newsfeeds.Com - Uncensored Usenet News
> ==----------
> >    http://www.newsfeeds.com       The #1 Newsgroup Service in the World!
> > -----= Over 100,000 Newsgroups - Ulimited Fast Downloads - 19 Servers
> =-----
>
>


Reply | Threaded
Open this post in threaded view
|

Re: If blocks are objects why can't they be stored literally in arrays:

Joseph Pelrine-4
In reply to this post by John Small
John Small wrote:

> Any way I have abandon my design attempt at pseudo virtual function
> (block) tables.

John

If you want to implement something like that, why don't you simply store the
blocks in a Dictionary? I've done that a number of times. Of course, try to
make sure that they're clean blocks too.
--
Joseph Pelrine [ | ]
MetaProg GmbH
Email: [hidden email]
Web:   http://www.metaprog.com

"If you don't live on the edge, you're taking up too much space" -
Doug Robinson


Reply | Threaded
Open this post in threaded view
|

Re: If blocks are objects why can't they be stored literally in arrays:

Andy Bower
In reply to this post by John Small
John,

> Array with: 1 with: 2 with: []
>
> in Dolphin 5  XP produces:
>
>     #(1 2 Array with: 1 with: 2 with: [])
>
> which looks like some kind of recursive mumbo jumbo because
>
>     (Array with:1 with: 2 with: []) at: 3
>
> yields itself:
>
>     (Array with:1 with: 2 with: []) at: 3
>
> I think the block closure is confused.

This effect is actually related to another thread (Block Source - a question
by Bill Schwab). Whenever an evaluation is compiled in a workspace it builds
an instance of CompiledExpression. The evaluation source is written into the
change log by the compiler and the CompiledExpression source pointer points
to the chunk where this is. Any blocks inside the CompiledExpression hold a
back-pointer to their context (in this case the CompiledExpression) and they
access their source from there. Unfortunately, the block doesn't hold any
additional information that identifies which section of the
CompiledExpression's full source represents the source for the block. Hence,
when a block reports its source it can only provide the full text of the
CompiledExpression that contains it.

Does this make it any clearer what is going on? Basically, the block is okay
but it's presentation is a bit screwy.

Best Regards,

Andy Bower
Dolphin Support
http://www.object-arts.com
---
Are you trying too hard?
http://www.object-arts.com/Relax.htm
---