Blocks, Advanced Use 
Author Message
 Blocks, Advanced Use

  Why do some methods in Smalltalk (/V) start with:

   [].

  I have read somewhere the reason, but can no
longer remember why. It is kind of a hack, to
force the creation of a new Home COntext, isn't it ?

Marcio



Tue, 29 Apr 1997 01:46:35 GMT  
 Blocks, Advanced Use
Bill,

Quote:
>> [Marcio says]
>>  Why do some methods in Smalltalk (/V) start with:

>>   [].

>[Bill says]
> but I don't think they are used in the way you describe.

  This method was taken from Envy/Developer for Smalltalk/V Windows 2.0.

--------------------- cut here -------------------------------------

queueWalkback: aString  makeUserIF: ifBoolean resumable: givenResumeLevel
        "Enter a walkback for current process
         in pending event queue.  Create new
         user interface process if ifBoolean
         is true."

    "** OTI (modified) Current process must be changed
    using accessor to set the correct interrupt configuration."

    | process firstTime callBack resumeLevel |
    [] yourself.
    firstTime := true.
    self enableInterrupts: false.
    ...

--------------------- cut here -------------------------------------

  And this one was taken from the Exception Handling System that
comes with T-Gen for ST/V Windows.

--------------------- cut here -------------------------------------
queueWalkback: aString  makeUserIF: ifBoolean resumable: resumeBoolean log: aLog
"Private - Enter a walkback for current process
         in pending event queue.  Create new
         user interface process if ifBoolean
         is true."
    | process firstTime callBack bindings |
    [].
    firstTime := true.
    Process enableInterrupts: false.
    bindings := CurrentProcess bindings.
    process := Process copyStack.
    ...

--------------------- cut here -------------------------------------

  So, what is the hack behind that ?

Marcio



Tue, 29 Apr 1997 21:44:43 GMT  
 Blocks, Advanced Use


Quote:

>  Why do some methods in Smalltalk (/V) start with:

>   [].

>  I have read somewhere the reason, but can no
>longer remember why. It is kind of a hack, to
>force the creation of a new Home COntext, isn't it ?

>Marcio

I wouldn't call it a hack, but blocks certainly does break some
fundamental object encapsulation rules. When you say some methods start
out with the [], can you give me an example.  Blocks are used very
frequently, but I don't think they are used in the way you describe.

Puzzled...

Bill Hyman



Tue, 29 Apr 1997 15:34:50 GMT  
 Blocks, Advanced Use


 >>>  Why do some methods in Smalltalk (/V) start with:
 >>>
 >>>   [].
 >>[Bill says]
 >> but I don't think they are used in the way you describe.

{ snip }

 >  So, what is the hack behind that ?

The inclusion of a block (any real block) in a method will cause the V
compiler to generate different local var (temps and args) accessing
bytecodes.  In particular, when executing a method without a block,
you can guarantee that the locals are on the stack and so access them
directly (faster).  If the method has a block then local accesses must
go to the method context so that their values are accessible from the
block (slower).

The methods using this hack will typically have to do with process
switching etc where they need to ensure that the accesses go to the
context and not the stack.  Think of it as a compiler pragma.

This is another case where V blocks fall short of the mark.  One of
the nice things about PPS, IBM (and I assume QKS) Smalltalk is that
they allow block locals and distinguish between blocks which access
outside of their immediate scope.  This way you only pay for what you
use.

BTW, I dont think that the difference between the ENVY/Developer
method you quoted and the original V method is significant here.  I
believe that that change has to do with other stuff.  Can't be suer
about that though as I don't have my VWin handy.  The fact that the
OTI method sends #yourself to the [] is likely to ensure that the []
doesn't get optimized out.  I seem to remember this optimization in
some compilers.

JEff

--
ato de, |m        -- He wandered off muttering, "I don't know.  I just don't
                     know.  "My, isn't he wise.", they said as he passed.



Thu, 01 May 1997 17:10:14 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. COURSES: High Level Design Using Verilog, Advanced Techniques Using Verilog, Portland, OR

2. COURSES: High Level Design Using Verilog, Advanced Techniques Using Verilog, Portland, OR

3. COURSES: High Level Design Using Verilog, Advanced Techniques Using Verilog, Portland, OR

4. COURSES: High Level Design Using Verilog, Advanced Techniques Using Verilog, Portland, OR

5. COURSES: High Level Design Using Verilog, Advanced Techniques Using Verilog, Portland, OR

6. COURSES: High Level Design Using Verilog, Advanced Techniques Using Verilog, Portland, OR

7. COURSES: High Level Design Using VHDL, Advanced Techniques Using VHDL, Portland, OR

8. COURSES: High Level Design Using VHDL, Advanced Techniques Using VHDL, Portland, OR

9. COURSES: High Level Design Using VHDL, Advanced Techniques Using VHDL, Portland, OR

10. COURSES: High Level Design Using VHDL, Advanced Techniques Using VHDL, Portland, OR

11. COURSES: High Level Design Using VHDL, Advanced Techniques Using VHDL, Portland, OR

12. std blocks vs blocks+cache ( was: block behavior)

 

 
Powered by phpBB® Forum Software