On 11/08/2012, at 9:38 AM, john skaller wrote:

> 
> Somehow this breaks my test program (I get an overload error in C++
> for an assignment). 

This is due to the following design fault:

(1,(2.2,"x"))

Unfortunately the current matching rules match 

U ** V with U = 1, V = 2.2,"x"

and then V matches A ** B with A = 2.2, B ="x"

making it look like 1,2.2,"x" 

Two solutions come to mind. The first is to insist the tail V is at least 
2 elements long.So U ** V will not match X * Y, only X * Y * Z.
This stops the recursion before Felix gets confused between a tail
of one element which is not a tuple and one which is. The confusion
arises because the proper rule is that the tail MUST be of form X ** Y
itself.

The second solution seems cleaner: may U ** V match ANYTHING.
If it is a nontuple T, set U = T and V = terminal. If its terminal, U and
V are both terminal. Terminal might be either unit or void. Unit seems
wrong: although 

        1, () 

is a valid tuple, Felix like to get rid of units using X * 1 = X
(i.e. applying the isomorphism). void avoids this problem,
but there are no values of type void to return. I'm not sure
matching against

        X ** void

to detect the end of the "list" will work. However it seems right that

        X ** void = X * unit (up to isomorphism)

Since a type variable cannot be void we would need two matches:

        C[X ** void]
        C[X ** Y]

where the first is most specialised and prevents Y being void.
The "unit" solution leads to an infinite list:

        X * Y = X ** Y ** 1 ** 1 ** 1 ** 1 ....

which of course can be trapped the same way as above.

--
john skaller
skal...@users.sourceforge.net
http://felix-lang.org




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to