Just a waring about type constraints: they don't propagate.
I tried this in the library:

  typedef i_schannel[t] = typesetof(ischannel[t], schannel[t]);

  proc _read[t,CHAN:i_schannel[t]](chan:schannel[t],loc:&gcptr[t]) {
    svc$ svc_sread$ cast[_schannel] chan, reinterpret[&gcaddress] loc;
  }


  proc read[t,CHAN:i_schannel[t]](v:&t,chan:CHAN) {
    var x: gcptr[t];
    _read(chan,&x);
    *v = *x;
  }

and it failed. I looked for a bug in the compiler, but there isn't
one: the bug is in the code.

The term:

        CHAN:i_schannel[t]]

in the type variables list for 'read', says that CHAN is a type
variable, and there is a constraint

        CHAN in typesetof(ischannel[t], schannel[t])

When a call is written, eg:

        read (&x,ch)

the types t and CHAN are deduced from the arguments. Then,
the constraint is checked.

Now when the inner call in read is made to _read, 
the call:

        _read(chan,&x)

has signature

        _read: CHAN * &t

This does matches _read, but the constraint of _read is NOT
satisfied because CHAN is a type variable. The binding
*inside* the read routine is fully polymorphic: it is bound
independently of any calls.

Even if you wrote:

        _read[t,CHAN]

is wouldn't help: the constraint on CHAN in the parameter
list is NOT passed on to _read: it's a constraint on
the type variable, but it isn't part of the type.

It is very important to note this because this:

  proc read[t,CHAN:i_schannel[t]](v:&t,chan:CHAN) {...

can actually be rewritten in sweeter form:

  proc read[t](v:&t,chan:!i_channel[t]) {...

so it looks like i_channel[t] is a type .. the '!' char
there shows it isn't, its a constraint on a generated
type variable: working example:

fun f:!fast_ints * !fast_ints -> int = "int($1+$2)";
print$ f$ 1,2; endl;


-- 
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
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to