Nasty bug in conversion functions .. that's the _ctor_int
type of thing Erick likes a lot:
var x = long(1);
This fails .. ok, so I have to do:
open Long;
var x = long(1);
Problem is this doesn't work at all:
var x = size(1);
CLIENT ERROR
Expected size to be struct or variable of function type, got typedef
size = ulong;
In ate.flx: line 4, cols 32 to 39
3:
4: var x = size(200);
********
5: ....
because 'size' is just a typedef, there's no
function called _ctor_size.
In fact .. this use is one of the main possible uses
of the _ctor_thing idea, since it provides a way
to convert a known type (such as 'int') in this case
to another type which is only known by an alias.
However this:
fun _ctor_size: int -> size = "$1";
does not work .. the problem is that the type
has to be a nominal type.
A coercion doesn't work either:
var x = (200: size);
gives:
CLIENT ERROR
Wrong type in coercion:
200 has type int<697>
whereas annotation requires ulong<703>
In ate.flx: line 5, cols 36 to 36
4:
5: var x = (200: size);
*
6: ...
The problem here is that C provides no overloading,
just conversions. C++ does overloading AND conversions
and the result is a mess. Felix avoids the mess by banning
implicit conversions. But we're left needing to do an explicit
conversion to type 'size' here, which is an alias for ulong
on my box, but we don't know that.
---------------------------------------------------
So .. I have fixed it so typedef's can now support constructor
conversions!
It isn't clear where to put these in the library though:
the _ctor_int, for example, is in module Int. There's no
module for aliases .. perhaps there should be.
--
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language