Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Compile-time binding

7 views
Skip to first unread message

Luke Palmer

unread,
May 28, 2003, 6:41:36 AM5/28/03
to perl6-l...@perl.org
I was reading about Haskell, and realized that I don't know what ::=
is supposed to mean (don't ask what that has to do with Haskell :-).
I know it's compile-time binding, but... what's compile-time binding?

Could someone who knows enlighten me, please?

Luke

David Storrs

unread,
May 28, 2003, 9:35:31 AM5/28/03
to perl6-l...@perl.org

Well, perhaps I'm mistaken, but I had understood it to mean simply
that the binding between variables and/or methods is established at
compile time, not at runtime. Specifically:

- Named variables have their addresses hardcoded during compilation
- Global variables given offset from start of global data area
- Local variables given offset from top of stack
- Object variables given offset from start of object data
- Normal function and method calls are hardcoded during compilation
- Normal functions have specific starting address in object file
- Object methods have specific starting address in object file
- Compiler is able to determine which function matches each call

(The above shamelessly cribbed from:
http://www.cs.sbcc.net/~shouk/polyhi/tsld005.htm, because it's 9:34 AM
and my brain doesn't wake up for at least another half hour.)


-Dks

David Storrs

unread,
May 28, 2003, 10:12:48 AM5/28/03
to perl6-l...@perl.org
On Wed, May 28, 2003 at 06:35:31AM -0700, David Storrs wrote:
> On Wed, May 28, 2003 at 04:41:36AM -0600, Luke Palmer wrote:
> > I know it's compile-time binding, but... what's compile-time binding?
> > Luke
>
> Well, perhaps I'm mistaken, but I had understood it to mean simply
> [...]

>
> - Named variables have their addresses hardcoded during compilation
> - Global variables given offset from start of global data area
> - Local variables given offset from top of stack
> - Object variables given offset from start of object data
> - Normal function and method calls are hardcoded during compilation
> - Normal functions have specific starting address in object file
> - Object methods have specific starting address in object file
> - Compiler is able to determine which function matches each call
>
> (The above shamelessly cribbed from:
> http://www.cs.sbcc.net/~shouk/polyhi/tsld005.htm, because it's 9:34 AM
> and my brain doesn't wake up for at least another half hour.)

(Responding to my own post) I suppose I should explicitly state that
P6 will probably implement things a little differently from the
details described above (e.g., I don't know that we will have
one-and-only one global data area), but the above describes the
general concept.

--Dks

Damian Conway

unread,
May 29, 2003, 4:45:55 PM5/29/03
to perl6-l...@perl.org
Luke Palmer asked:

> what's compile-time binding?

A normal binding:

$name := expr;

is a run-time operation that installs its RHS operand as a new implementation
for the LHS symbol. That is, it means:

$CurrentPackage::{'$name'} = \(expr)

(with some special magic that only enreferences C<expr> if it's not already a
reference to a scalar).

A compile-time binding:

$name ::= expr;

*pre*-installs its RHS operand as an implementation for the LHS symbol. That
is, it means:

BEGIN { $CurrentPackage::{'$name'} = \(expr) }

(with the same special enreferencing magic).

In other words, C<::=> is to C<:=> as a macro call is to a subroutine call.

Damian

0 new messages