[M3devel] generics w/o explicit instantiation in build system?
Jay K
jay.krell at cornell.edu
Fri Sep 28 04:49:01 CEST 2012
Given GENERIC INTERFACE Vector(T);
I'd like to say:
TYPE Foo = REF RECORD ... END;
VAR foo := NEW(Sequence(Foo));
without messing around with any Quake code.
Is this really so much to ask?
Today instead I have to either mess around with Quake,or store REFANY and constantly NARROW them.Like storing a void* in a container, but safer and slower.
C++, Java, and C# all provide about the same thing here.
>From a language point of view, I think this is easy.The only complication is what name to give the thing internally.There are a few obvious choice: Prepend/append the current module/interface. This is easiest. But might lead to some bloat.
Prepend/append a hash. Or maybe nothing. This provides for single instancing, It either requires builder or linker cooperation.
Mark the code as "file level static" using whatever mechanism C does. This is presumably easy and might lead to some bloat. Given a 64bit Sequence(INTEGER), Sequence(LONGINT), the Microsoft linker will automatically combine any resulting code -- when optimization, it combines duplicate code that is "the same" but has different names. Note that it is easy to inhibit, e.g.: int F1() { static int i; return ++i; } int F2() { static int i; return ++i; } are NOT the same, because they must reference different "i". Thoughts? - Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120928/a36c68f6/attachment-0001.html>
More information about the M3devel
mailing list