Jorge Marques Pelizzoni wrote:
In special, a pattern like
l(F:V ...) would be intrinsically non-deterministic, don't you think?
Perhaps you should first explain what 'intrinsically non-deterministic'
means to you.
Well, F:V might match against any feature-value pair.
... unless...
you impose the standard arity order there, but I cannot really see why you
would want that.
In fact, there is a difference between l(f:V) and l(F:v) in that there
is no requirement on the uniqueness of values in a record, and in this
sense the pattern l(F:v ...) would be nondeterministic, provided no
requirement on sorting the features. But I don't see why the question
'does it contain the feature f?' would have to be, in general, more
interesting than 'does it contain a feature with the value v?'
If you intend to process each feature-value pair that way
(much like taking the head of a list) that would be most unadvisable. You
would generate a series of record "types" (i.e. different arities by using
Record.subtract), which is really not healthy memory-wise.
That would be sort of nonsense, of course. Actually, what I wanted was
patterns capturing the label (no nondeterminism here) and patterns
capturing all features (no nondeterminism, provided sorting), as in L(),
L(f:_), L(...), l(F:_ G:_ H:_) etc. (Where L() would have to match only
atoms, unlike L.)
In other words, your proposal seems to cater for exactly those cases where
it is advisable to use Record.toListInd, Arity, Record.forAllInd and so
on.
No, that was not the purpose.
By the way, the case statement supports some of the cases you stated in a
less graceful manner. For example:
You see how ugly it gets. And since it *is* possible, and not a priori
useless, why not have patterns for that, esp. that it should not be too
complicated implementationwise.
vQ
----------------
declare
proc {Test X}
case X of
l(...) andthen {Width X} == 1 then
F = {Arity X}.1
in
{Browse F#X.F}
[] l(...) andthen {Width X} > 1 then
F = {Arity X}.1
in
{Browse F#X.F}
{Test {Record.subtract X F}}
[] Rec andthen {IsRecord Rec} andthen {HasFeature Rec f} then
{Browse f(Rec.f)}
else {Browse nothing} end
end
{Test l}
{Test l(a:1)}
{Test l(2 b:3)}
{Test k(f:3)}
-----------------------
Cheers,
Jorge.
_________________________________________________________________________________
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