Do everything in Java…

Paulo Pinto via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 10 06:16:46 PST 2014


On Wednesday, 10 December 2014 at 12:24:56 UTC, Tobias Pankrath 
wrote:
> On Wednesday, 10 December 2014 at 10:24:53 UTC, Paulo  Pinto 
> wrote:
>> On Wednesday, 10 December 2014 at 08:43:49 UTC, Kagamin wrote:
>>> On Tuesday, 9 December 2014 at 20:55:51 UTC, Dicebot wrote:
>>>> Because you don't really create a template that way but 
>>>> workaround broken function behavior. It is not the usage of 
>>>> empty templates that is bad but the fact that plain 
>>>> functions remain broken => not really a solution.
>>>
>>> You can compile against phobos sources instead of interface 
>>> files.
>>
>> This cannot be the solution if D aspires to be used in 
>> contexts where binary libraries are used.
>>
>> C++ is excused to have template code in headers given the 
>> primitive tooling, but languages like Ada and Modula-3 support 
>> proper information hiding for generic code.
>>
>> --
>> Paulo
>
> A binary blob requirement makes no sense for a standard library.

And yet that has been the way it always worked in the Mesa linage 
of languages.

Mesa, Modula-2, Modula-3, Ada, Oberon, Object Pascal  ....

>
> Would you like to explain how the proper information hiding 
> support works for generic code in Ada? I'm really curious how 
> that could work in D.

The libraries contain the required metadata for symbol tables and 
code locations that need to be extracted into the 
executable/library.

Package definition files contain the minimum information the 
compiler needs to know to search for the remaining information.

Example,

-- Package header
generic
   type Element_T is private;
package functions is
   procedure Swap (X, Y : in out Element_T);
end functions;

-- Package body
package body functions is
   procedure Swap (X, Y : in out Element_T) is
   begin
     -- implementation
   end Swap;
end functions;

-- importing it
declare
   package functions_Int  is new functions (Int);
   use functions_Int;
   x, y : Int;
begin
   x := 1;
   y := 2;
   Swap(x, y);
end;


Lots of options are possible when the C compiler and linker model 
aren't being used.

..
Paulo


More information about the Digitalmars-d mailing list