POV-Ray : Newsgroups : povray.off-topic : Haskell raving : Re: Haskell raving Server Time
15 Nov 2024 15:16:38 EST (-0500)
  Re: Haskell raving  
From: Invisible
Date: 6 Nov 2007 04:42:03
Message: <473036eb$1@news.povray.org>
Darren New wrote:
> Invisible wrote:
>> No, the latter; you can't have an array who's elements are a 
>> particular type since the compiler won't know how big it is.
> 
> Right. Not unusual in compiled languages, that.

Indeed.

>> (Notice that Haskell has no such limitation; you can expose no 
>> implementation information to THE PROGRAMMER whilst this information 
>> IS still exposed to THE COMPILER. 
> 
> So, I can have a module that changes the size of the objects it works 
> with, and the compiled code of the caller doesn't have to see that?

No.

If your code calls my module, and my module changes internally, you will 
have to recompile your code. You don't need to *change* your source code 
in any way, just recompile it.

The optimiser performs moderately extensive cross-module optimisations.

[My code might get inlined into yours. My types (which you, the 
programmer, can't see the representation for) might get unboxed into CPU 
registers during tight inner loops in your code. My module might define 
transformation rules that rewrite parts of your program when you compile 
it. And you don't have to care about any of this...]

> I.e., to make this happen, does the caller need the source code to my 
> module? Or can I compile that module, give you the executable (or 
> library), and you can allocate the right size object without knowing it?

Suppose I write some module named "Banana". In order to compile your 
code against my module, you will need to possess either

* The source code ("Banana.hs")

* The object code ("Banana.o") + the interface file ("Banana.hi")

As long as you have one or the other, you can compile against my code. 
So yes, I can write Banana.hs, compile it (thus generating Banana.o and 
Banana.hi) and give you the latter files (which are both binary). You 
won't have my source code, but you can still compile against it.

Indeed, the compiler ships with compiled base libraries, and doesn't 
*provide* source code unless you download it seperately. (Which is just 
as well, because it's quite large and takes a while to compile...)

(As an aside, in order to use the object code file, you'll need to be 
using the exact same compiler version as me. On the same platform, 
obviously.)

> Cause, like, doing that when you're distributing library sources is 
> pretty easy.

Um... I'm not sure exactly which statement you're trying to make.


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.