bug or misunderstanding?

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

bug or misunderstanding?

Randal L. Schwartz

Squeak 3.9 release + level playing field
Seaside 2.8.

Top level component is this:

    renderContentOn: html
      | holder |
      html heading: 'test of callback'.
      html form: [
        html textInput callback: [:e | holder := e].
        html submitButton callback: [Transcript show: holder; cr]
      ].

Why is "holder" nil here?  I can see that my textinput callback is
called first.  Shouldn't both of the callbacks share the same
reference to "holder"?

Bug or my misunderstanding?  Is there a fix or a workaround, or a
better way to do this?

This works fine if I make holder an instvar, by the way, but I don't
want to do that as it complicates the example.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[hidden email]> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: bug or misunderstanding?

Lukas Renggli
>  Why is "holder" nil here?  I can see that my textinput callback is
>  called first.  Shouldn't both of the callbacks share the same
>  reference to "holder"?

This is a long standing bug of Squeak. Of course nobody cares to
integrate the existing fix, as it consists of more than two new
classes. The fix is called 'Closure Compiler' and existing, tested and
working for years.

Blocks are badly broken in Squeak.

Lukas

PS: As a workaround you can store your data within an inst-var, or if
you want to use a temp within a ValueHolder that you store in the
temp.

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

RE: bug or misunderstanding?

Ramon Leon-5
In reply to this post by Randal L. Schwartz
> Top level component is this:
>
>     renderContentOn: html
>       | holder |
>       html heading: 'test of callback'.
>       html form: [
>         html textInput callback: [:e | holder := e].
>         html submitButton callback: [Transcript show: holder; cr]
>       ].
>
> Why is "holder" nil here?  I can see that my textinput
> callback is called first.  Shouldn't both of the callbacks
> share the same reference to "holder"?
>
> Bug or my misunderstanding?  Is there a fix or a workaround,
> or a better way to do this?
>
> This works fine if I make holder an instvar, by the way, but
> I don't want to do that as it complicates the example.
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. -

It's because Seaside calls fixCallbackTemps on callback blocks giving each
block it's own copy of locals so that you don't run into weird problems when
doing loops and expecting the block to act as a proper closure.  Without
doing this, every reference to "each" in loop would end up referencing the
last item assigned to "each".  As much as possible, I just avoid using temps
and state in render methods unless it's absolutely necessary.

Ramon Leon
http://onsmalltalk.com

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside