I have fixed the problem with cstructs now, but this raises an interesting 
question.
Consider this program:

fun f: int -> int = "$1" requires A;
println$ f 1;

Should this compile? At first glance you'd say no, because "A" isn't available
which should remove "f" and thereby break the print.

But consider this:

header A = "..";
header A = "..";
fun f: ... requires A;

By specification, both headers are emitted if f is used.
In other words the *set* of headers tagged A are emitted.
In other words it isn't an error if the set contains 1 member,
or two members, so why not no members?

It isn't what I expected, but it is, in fact consistent!

So what actually happens in the malloc example is:

stdlib_h is defined in the wrong place, and so isn't found when
malloc is used, but still, felix correctly emits .. nothing in support
of the malloc.

But the code compiles by luck, because stdlib.h is a header that
is always emitted by the compiler.

So that's why it works: there's no error.

The only way to fix this is require exactly one unique tag. 
After all you can chain tags:

header A = " .. ";
header B = " .. ";
header AB requires A, B;

Not sure if I like this though. Comments?

In fact, the felix requirements expressions are quite complex and
general: you can use and's and or's and not's etc.. and it isn't clear
what that means either :)

Original I though of:

proc create_thread: int = "posix::create_thread ($1);" requires POSIX;
proc create_thread: int = "windows::create_thread($1);" requires WIN32;

as a way of selecting bindings, with the semantics above this isn't possible.

but we can always add predicates .. for example

requires defined(posix); // shades of c-pre-proc ...;(

This leaves in question what "and" and "or"mean.. I expected

require A and B

to means the same as

require A,B;

that is, to require both, and

 require A or B;
 
to mean: try A, but if not found use B instead: a simple example of the idea
is to have

  require epoll or poll or select;

meaning use epoll if available, otherwise poll, and if that isn't available use 
select.

however a set-wise interpretation has almost the opposite meaning:

  require A or B;

means to require the union, which is both A and B, whereas requiring A and B
would be the intersection, which would currently be empty (since one insertion
can't have more than one tag).

BTW: I believe the problem of resolving such dependencies with alternatives
is NP-hard, which is why production package managers like Debian can't
effectively allow this option.

--
john skaller
skal...@users.sourceforge.net





------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
Felix-language mailing list
Felix-language@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to