[Seaside] sending messages in lists

Avi Bryant avi@beta4.com
Mon, 3 Jun 2002 16:54:44 -0700 (PDT)


On Mon, 3 Jun 2002, Tim Rowledge wrote:

> <li sea:id="each/practiceTest"> <a sea:id="doPracticeTest:"> Practice
> Test [each.id] </a> {self remainingTries: each}
>
>  - where I can't find anything to help me work out how to phrase the {}
> part. I could have sworn I saw it somewhere...
>
> Oh ,yes,
> #remainingTries: aTest
> 	^aTest allowedAttempts - user attemptsForTest: aTest
>
> So, how can one insert the result of sending a message like that into
> the list items?

<the part you need to know>

remainingTries
  |test|
  test := locals at: #each.  "or 'test := locals last'"
  ^ test allowedAttempts - user attemptsForTest: test

</>

<rambling>

I've vaguely thought about sending the value of 'locals last' any time you
have a keyPath that takes an argument, so that you could have

<li sea:id="each/practiceTest">...  [remainingTries:] </li>

and then just write #remainingTries: like you did above.  This could be
extended for nested loops so that methods taking two arguments would get
given the top two items of the locals stack, etc.  One potential advantage
of this would be if the concept could be extended far enough that the
locals stack was eliminated entirely and you had to explicitly capture any
locals you wanted.  This would save on memory, since right now the entire
locals stack is copied at evey point it could conceivably be needed (I
know, I know, it ain't rainforests).

a