Re: A side-effect example

/ Alessandro Vernet <avernet@orbeon.com> was heard to say:
| A parallel can be made between the pipeline language, and other
| programming languages that have a concept of function. Components can
| be compared to functions, and a steps to function calls.

Yes.

| With this in mind, let's look 2 piplines.
|
| 1) First pipeline:
|
|     main = <doc/>
|     t1 = timestamp()
|     t2 = timestamp()
|     t3 = timestamp()
|     result = append(main, t1, t2, t3)
|
| I think it is reasonable to expect a result like:
|
|     <doc>
|         <t>43151</t>
|         <t>43153</t>
|         <t>43159</t>
|     </doc>
|
| 2) Second pipeline:
|
|     main = <doc/>
|     t = timestamp()
|     result = append(main, t, t, t)
|
| Here there is only one steps that uses the timestamp component and the
| output of this step is used 3 times. In this case, I will expect the
| result to look like:
|
|     <doc>
|         <t>43151</t>
|         <t>43151</t>
|         <t>43151</t>
|     </doc>
|
| I don't see the benefit of saying that if timestamp is called multiple
| times, it has to always return the same result. If the authors goes
| through the trouble of writing multiple calls to the same component
| (as in pipeline 1 above), it is likely that he wants that step to run
| multiple times.

Indeed. That's the sort of reasoning that lead me to make the proposal
that I made in response to Alex M.:

We've had two telcons of discussion about how to expose this
information and we don't seem to be approaching consensus, so let's
try a new approach.

I propose that we say that all components are non-functional. That is,
a pipeline implementation must behave as if it evaluated a component
every time it occurs [in the context of this message, everytime it is
used in a step]. "Must behave as if" is spec-ease for "implementations
that are clever enough to determine with certainty that a component
is, in fact, functional are free to cache the intermediate results
because by golly if it is, no one will be able to tell."

Pipeline authors who are concerned about controlling the number of
times a component is executed can use the 'tee' component to split
output and thereby be confident that it will be evaluated only once.

                                        Be seeing you,
                                          norm

-- 
Norman Walsh
XML Standards Architect
Sun Microsystems, Inc.

Received on Wednesday, 26 April 2006 19:53:14 UTC