Do everything in Java…

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Dec 10 10:28:41 PST 2014


On Wed, Dec 10, 2014 at 06:15:48PM +0000, Paulo Pinto via Digitalmars-d wrote:
> On Wednesday, 10 December 2014 at 16:56:24 UTC, Iain Buclaw via
> Digitalmars-d wrote:
[...]
> >In D, this should be akin to:
> >
> >// Package header
> >module functions;
> >void Swap(T)(out T x, out T y);
> >
> >// Package body
> >module functions;
> >void Swap(T)(out T x, out T y)
> >{
> >  // Implementation
> >}
> >
> >// Importing it
> >import functions : Swap;
> >void main()
> >{
> >  int x = 1;
> >  int y = 2;
> >  Swap(x, y);
> >}
> >
> >Iain
> 
> But the current object model doesn't support it, right?
> 
> At least my understanding is that you need to have the full body
> visible.
[...]

Yeah, the compiler cannot instantiate the template without access to the
full body. It *could*, though, if we were to store template body IR in
object files, perhaps under specially-dedicated object file sections. It
wouldn't prevent reverse-engineering (which is moot anyway when
templates are involved), but it *would* work as an "opaque" library
interface file.


T

-- 
Food and laptops don't mix.


More information about the Digitalmars-d mailing list