[Swift-devel] strange behavior evaluating function call as trace arg

Ben Clifford benc at hawaga.org.uk
Thu Feb 5 10:06:39 CST 2009


On Thu, 5 Feb 2009, Michael Wilde wrote:

> I dont understand this - can you clarify?
> 
> I understand an "lvalue" in swift to be one of:
> - a var (eg var=value)
> - an array element (eg a[i]=value)
> - a struct element (eg s.a=value)

yes.

> But swift procedures do indeed return a list of values, right?

no.

> So below when you say "Procedure calls *must* have an lvalue to their l to
> give them somewhere to put their l" do you mean "Procedure calls can only be
> invoked form assignment statements, and *must* have the same number of lvalues
> on the lhs of the assignment to give them somewhere to put all of their return
> values" ???

yes. 

Ignore the cardinality of return values - that's irrelevant to this.

When evaluating a @function call what comes out is a new DSHandle object 
that has been created by something inside that @function.

When evaluting a procedure call, the procedure expects to be given 
existing DSHandle object(s) to place its 'return values' into. Return 
values in the procedure case encompass files as well as primitive values. 

That mechanism is how, when you say:

(file f) p() {
  touch @f
}

file myfile <"foo">
myfile = p();

the procedure is able to figure out the filename "foo" to touch, even 
though its a return parameter. The mapping is attached to the DSHandle 
object, which comes into existence due to the 'file myfile' declaration.

-- 




More information about the Swift-devel mailing list