Francois Maltey <[EMAIL PROTECTED]> writes:
> Dear Ralf and all,
>
> > In particular [List and] Record provide such bracket function of type [...]
> > which allows the usual list construction.
> >
> > (in Record(a: Integer, b: String, c: Float))
> > bracket: (Integer, String, Float) -> %
> > which allows
> >
> > Arec: Record(a:Integer, b:String, c:Float) := [123,"azerty",1.2e-3]
> >
> > What else would you want?
>
> Indeed, the bug is in my mind... Let me explain :
>
> In my mind theses two cases aren't equivalent :
>
> // 1 // List is very easy.
>
> I only type L := [1,2,3] without type
> and I play with L.1, L.2...
>
> // 2 // Record is too subtle.
>
> Not only because I use less Record than List
> but because // A // I must declare this type
> and // B // I must choose the field name. (It's too complex for me)
In fact, A follows from B. In axiom, the interpreter cannot coerce [1, "s"]
automatically to Record(a: Integer, b: String), because it has no way to guess
the labels.
Possibly, this is the reason why Aldor allows Records also *without* labels:
-------------------------------------------------------------------------------
%1 >> #include "aldor"
Comp: 70 msec, Interp: 10 msec
%2 >> #include "aldorinterp"
Comp: 40 msec, Interp: 0 msec
%3 >> import from Integer, String, Record(Integer, String)
Comp: 10 msec, Interp: 0 msec
%4 >> a := [1, "s"]
() @ Record(AldorInteger, String)
Comp: 0 msec, Interp: 40 msec
%5 >> (x,y) := explode a
() @ AldorInteger, String
Comp: 0 msec, Interp: 0 msec
%6 >> x
1 @ AldorInteger
Comp: 0 msec, Interp: 60 msec
%7 >> y
s @ String
Comp: 0 msec, Interp: 0 msec
%8 >> import from Boolean, Record(String, Boolean)
Comp: 0 msec, Interp: 0 msec
%9 >> b := ["hi", true]
() @ Record(String, Boolean)
Comp: 0 msec, Interp: 10 msec
%10 >> (r, s) := explode b
() @ String, Boolean
Comp: 0 msec, Interp: 0 msec
%11 >> r
hi @ String
Comp: 0 msec, Interp: 0 msec
%12 >> s
T @ Boolean
Comp: 0 msec, Interp: 0 msec
-------------------------------------------------------------------------------
of course, the Aldor interpreter does very little guessing, but note that from
line %8 onwards, we have two Record types in scope, and the Aldor interpreter
is still able to infer the type of b := ["hi", true].
However, turning to Axiom again, as soon as we have a type Any in scope, the
interpreter has no way to know whether we mean List Any or Record(String, INT)
with ["a", 1].
We could, of course, unexpose Any, and introduce unnamed Records, a function
explode and multiple values. I'm not sure whether this wouldn't create other
usability problems.
By the way Record(Integer, Integer) is not allowed in Aldor. I do not
understand why, isn't that a bug:
%13 >> import from Record(String, String)
...........................^
[L13 C29] #1 (Error) Duplicate selector/type pair within Record, RawRecord or
Union.
Martin
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
open-axiom-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/open-axiom-devel