On Sat, 2006-09-02 at 09:37 -0400, Peter Tanski wrote:
> On Sep 2, 2006, at 3:00 AM, skaller wrote:

> In any case, I asked how you are implementing this because if it  
> seems like a laborious project maybe another set of hands would help.

So here we go: read page 6 of the pattern calculus paper.
There is a nasty definition there of matchable forms.

One of the reduction rules yields an undefined results
as a consequence.

Later, Jay claims the system is confluent, but this
is a conceit. It is only confluent because of the
matchable forms constraint.

That constraint appears to be equivalent to an evaluation
order requirement, in other words, the unconstrained
calculus isn't confluent :)

Unfortunately I can't figure out how to check the
constraint. I'm not even sure it is possible.

On page 8 you can see an example of an if/then/else
branching construction. Here is some test code
for that:

-----------------------------
// let is try the conditionals

type True = "int"; // don't care about the implementation
type False = "int";

var dum1: 
  typecase [] True => 
    typecase [x] x => int endcase
  endcase
  True long
= 1; // int

var dum2: 
  typecase [] False => 
    typecase [x] x => int endcase
  endcase
  True long
= 1L; // long
------------------------

This works as expected. But:

---------------------------------------------
// THIS DOES NOT WORK because unconstrained
// pattern matching is NOT confluent

typedef fun ite(b:TYPE, s:TYPE, r:TYPE): TYPE =>
  typecase [] True => 
    typecase [x] x => s endcase
  endcase
  b r
;


//var dum1: ite (True, int, long) = 1; // int
//var dum2: ite (False, int, long) = 1L; // long

// What happens is the function form reduces
// the body before substitution .. and this
// reduction tests term b, not term True or False.

// The reduction shouldn't be applied, because
// it isn't a matchable form: b is neither a case
// nor a constructor nor a variable in []
// It's actually a 'free variable' in this context.
// but I don't test for this!
//
// It isn't possible to do so either? since we don't
// actually know what the constructors are
//
// yet .. this works with MY typematch facility.
// it does recognize when a match can't be reduced
----------------------------------------------------

My typematch also fails for a different reason:

---------------------------------------
typedef fun ite2(b:TYPE, s:TYPE, r: TYPE): TYPE =>
  typematch b with
  | True => s
  | False => r
  endmatch
;

var dum11: ite2 (True, int, long) = 1; // int

[lookup_name_in_env]: Name 's' not found in environment (depth 2)
In a.flx: line 120, cols 13 to 13
119:   typematch b with
120:   | True => s
                 *
121:   | False => r
-------------------------------

Woops, looks like I messed up the environment construction
(s is of course a parameter, so it is a bound variable,
the diagnostic is saying it is a free variable .. :)


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to