FLTK native in 'D'. Would that be useful?

John Reimer terminal.node at gmail.com
Thu Jul 27 15:32:58 PDT 2006


On Thu, 27 Jul 2006 12:57:56 -0700, MatthiasM <dm at matthiasm.com> wrote:

> John Reimer wrote:
>>  I think one improvement would be to drop all Fl_* prefixes on class  
>> names like FLTK 2.0 does.  I looked and 2.0 and found it world's better  
>> looking than the older 1.1.
>>  Is that possible?
>
> Yes, that would be possible. I do agree on the looks. My original idea  
> was to do the port as compatible as possible, so that existing FLTK apps  
> can be easily ported, which is why I left the original class names alone.
>
> I am still not a hundred percent familiar with the "module" keyword full  
> names. My first choice would be to map class names like this: (best of  
> both worlds)
>
>    C++:           D:
>
>    Fl_Window  ->  fl.Window (or just Window, if no name conflict)
>    Fl_Group   ->  fl.Group
>    fl_draw()  ->  fl.draw()
>


Yes, that would be a solution.  They are called "renamed imports" and are  
available as of 0.163. But you would need to do it slightly different with  
GDC 0.19 which is still based off of 0.162 (or earlier?). Version 0.163  
implements an improved import system.  In GDC 0.19, you probably can do  
the same using "alias" for now.


> How would I implement this, assuming the fltk path would be for example:
>
>    gui/fl/window.d
>
> and using
>
>    import gui.fl.window;


Using dmd 0.163, try this:

# // import all symbols in gui.fl.window module into the 'fl' namespace
#
# import fl = gui.fl.window;
#
# void main()
# {
#     ...
#     auto win1 = new fl.Window( );
#     ...
# }


Using GDC 0.19 (equivalent to 0.162), I think you can do this for now  
(next version should support the new import features, though):


# import gui.fl.window;
# // rename the module namespace
# alias gui.fl.window fl;
#
# void main()
# {
#     ...
#     auto win1 = new fl.Window();
#     ...
# }

Others might have some more suggestions.  But I think that's an  
improvement over using Fl_ prefix.

All the best,

JJR



More information about the Digitalmars-d-dwt mailing list