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

John Reimer terminal.node at gmail.com
Sun Jul 30 12:39:55 PDT 2006


On Sun, 30 Jul 2006 08:57:51 -0700, Bruno Medeiros  
<brunodomedeirosATgmail at SPAM.com> wrote:


>>>    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
>
> But there is a problem with that, it won't work if one wants to import
> several gui.fl.* modules.
>
>    import gui.fl.window;
>    alias gui.fl.window fl; // rename the module namespace
>    import gui.fl.group;
>    alias gui.fl.group fl; // <- fl name conflict
>
> There are some particular aspects like these when converting code from a
> language with a namespace naming system like C++ (or C#) to D's
> package+module system. The best solution I think is to create a "name
> forwarding" module that will emulate the fl namespace:
>
>    module gui.fl.flnamespace;
>
>    public import gui.fl.window;
>    public import gui.fl.group;
>    public import gui.fl.draw;
>
> Usage:
>
>    import gui.fl.flnamespace;
>    alias gui.fl.flnamespace fl;
>
>    ...
>
>    fl.Window ..
>    fl.Group ...
>    fl.draw();
>
> Alternatively you can also redesign the way you structure FLTKs classes
> and accesses in D's naming system.
>


Ah yes, you are right, of course.  I didn't think far into the problem.   
Thank you for pointing that out. It's good at least, that there are  
alternatives available.

-JJR



More information about the Digitalmars-d-dwt mailing list