On 21/08/2012, at 4:04 AM, Dobes Vandermeer wrote:

> 
> Er, wait ... does Felix have NULL?

Of course it does. 

        gen malloc : int ->  address = "malloc($1)";

How can we proceed if the result can't be NULL?

We have to account for how C/C++ behaves.

>  I thought you could only have an option pointer, which the compiler does 
> require you to "check" before you use it using match... right?

the type system supports 3 kinds of pointers (it should be four I think).

        &int -- not checked
        @int -- checked
        +int -- not checked can  be incremented

The idea is you use &int for a pointer to an object, it cannot be NULL
and it cannot be incremented. It also shouldn't dangle.

We use @int if the pointer can be NULL. You can check it by a coercion
to a &int which throws if he pointer is NULL. You can deref it directly,
which throws if the pointer is NULL. Or you can do a match on it,
and handle the NULL case yourself.

The +int style is for pointers into arrays, these can be incremented.
It's assumed  they're not NULL, cannot dangle, and cannot go past
the end of an array. This isn't enforced.

Probably there should be a "null or incrementable pointer".
Probably there should be a "incrementable but cannot go off the end".
pointer as well, as well as a "incrementable and throws if it goes
off the end and you deref it".

At present Felix can sometimes dynamically check if an array pointer
goes off the end, and indeed sometimes it can check statically!

It's also possible to have a modular pointer (wraps around, so cannot
go off the end). this is related to modular integers (wrap around
so cannot overflow).

There are no pointers to const (you have to cast away const in C function
returns to comply).

--
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