Re: [fricas-devel] lifting of properties to Record

14 views
Skip to first unread message

Ralf Hemmecke

unread,
Sep 10, 2015, 3:42:01 AM9/10/15
to fricas...@googlegroups.com, aldor-devel
Well, looks promising.

You probably mean that there is something like

extend Record(T: Tuple Type): with _
if _and(t has PrimitiveType for t in T) then PrimitiveType
== add ...

put into a library file.

(BTW, would

extend Record(T: Tuple PrimitiveType): PrimitiveType == add ...

be equivalent?)

But I fear that this is just a runtime check. So whenever the respective
domain/record gets instantiated, it would be known whether it also
exports PrimitiveType or not, but the compiler cannot take advantage of
this statement to produce better code. Or can it?

Ralf

On 09/10/2015 09:10 AM, Peter Broadbery wrote:
> It is almost possible in aldor, given Record(T: Tuple Type), one could say
> 'if _and(t has PrimitiveType for t in T) then PrimitiveType'. This won't
> work at the moment, but I think the restriction on conditional exports
> using 'has' isn't required. I'll experiment a bit later.
> On Sep 10, 2015 6:20 AM, "Ralf Hemmecke" <ra...@hemmecke.org> wrote:
>
>>> If all fields have SetCategory, then record should have SetCategory
>>> too. Currently Spad cheats and unconditionally asserts SetCategory.
>>> If Aldor unconditionally considers records to _not_ have
>>> SetCategory, then this looks like serious limitation of Aldor.
>>
>> The SPAD compiler cheats. But even if it doesn't, your rule looks like
>> "the spad compiler knows SetCategory" and so SetCategory would be more
>> or less a type belonging to the Spad Language and not to the library.
>>
>> Would you agree that record should also export BasicType if all its
>> fields have BasicType? Or Monoid if all its fields have Monoid? Where do
>> you draw the line? What if I produce another library where my
>> "SetCategory" type is called "Setcategory" or simply "Set"?
>>
>> Some properties can be lifted, but some not. You are right that Aldor
>> does not allow to express such a lifting statement in terms of the
>> language, but still I'd prefer rather extend the language to express
>> such lifting (even if the number of fields of Record is arbitrary)
>> rather than including library knowledge into the compiler.
>>
>> Just my 2 cents.
>>
>> Ralf

Reply all
Reply to author
Forward
0 new messages