[erlang-questions] How to get the line number of current executable code?

Richard A. O'Keefe ok@REDACTED
Wed Aug 20 07:44:33 CEST 2008


On 20 Aug 2008, at 3:39 am, Andras Georgy Bekes wrote:

>>  -pure([f/n,...]).
>> directive, such as NU Prolog had.
>> This would make a verifiable claim that the function(s) named would
>> only call functions that are themselves pure
> What happens if a pure function calls a function that is not pure?
>
> I mean, the compiler just can't check it.

Yes it can.  That's the whole POINT of -pure declarations.
The NU Prolog system *could* and *did* check this.

> Of course it can check local
> functions, but a function in another module can not be trusted.

Cannot be trusted?  Sure it can.  You haven't seen a complete
proposal, because I have other maddened grizzly bears to stun,
but the idea is that
  - the meta-data for a module records which exported functions are
    pure and which are not
  - when the compiler notes a pure function calling a function
    from another module, it records a dependency on that function
    being exported as pure
  - when a module is loaded, the run time system checks that
    every function it tries to import as pure from some other
    module IS pure if that module is already loaded,
    every module that depends on this one exporting some
    function(s) as pure is satisfied.
    If either check fails, the module is not loaded.

This takes care of the "another module" issue.
The tricky one is higher order functions.
I actually came up with this idea back shortly before
'funs' were added to the language, and dropped it when they
came in.  There are basically two ways out: one is to say
that a pure function can't be or call a higher order function,
and the other is to use some sort of type system.





More information about the erlang-questions mailing list