bug or misunderstanding?

View: New views
3 Messages — Rating Filter:   Alert me  

bug or misunderstanding?

by Randal L. Schwartz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


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
<merlyn@...> <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
seaside@...
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

Re: bug or misunderstanding?

by Lukas Renggli :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

>  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
seaside@...
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside

RE: bug or misunderstanding?

by Ramon Leon-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> 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
seaside@...
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside