Torsten Anders wrote:
On Sep 12, 2007, at 9:02 PM, Wacek Kusnierczyk wrote:
I found it convenient
to be able to ignore the wrapper (the label/features of a record) of a
message and get just the content (values; so the pattern _(_:V) might be
useful, for example)

The syntactic sugar introduced by pattern matching does not support this, as it wouldn't be as efficient (feature access is efficient constant time access): _(_:V ...) would require traversing the whole record.

Not necessarily in this case: this should pick the value of the first field (it depends on the actual implementation, which I prefer to stay unaware of in this context). I can also imagine that every pattern matching of records requires traversing the whole record in just the same way this would, if it did.
However, with if and some record functions you can implement such a check yourself easily (without any syntactic sugar..). Test whether a given value is a record whose arity length is exactly one and whose value at its single feature is V.
Fully aware of this solution. Not closely as elegant syntactically as case R of _(_:V ...). And you still have to rely on the fact that Arity returns a sorted list -- if the arity is stored sorted with other data of the record, the pattern should not be particularly difficult or inefficient to implement.

Thanks for the comments, I'll not try to convince you further.

vQ

declare
R = test(foo:bar)
V = bar

{Browse
if {IsRecord R} andthen
    local A = {Arity R} in
       {Length A} == 1 andthen
       R.(A.1) == V
    end
then matches
end}

Best
Torsten

--
Torsten Anders
Interdisciplinary Centre for Computer Music Research
University of Plymouth
http://strasheela.sourceforge.net
http://www.torsten-anders.de


_________________________________________________________________________________ mozart-users mailing list [email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

_________________________________________________________________________________
mozart-users mailing list                               
[email protected]
http://www.mozart-oz.org/mailman/listinfo/mozart-users

Reply via email to