develooper Front page | perl.perl6.compiler | Postings from January 2012

Re: Announce: Niecza Perl 6 v14

Thread Previous | Thread Next
From:
Darren Duncan
Date:
January 31, 2012 00:15
Subject:
Re: Announce: Niecza Perl 6 v14
Message ID:
4F27A315.10608@darrenduncan.net
Stefan O'Rear wrote:
> Niecza now supports constant folding!  If you mark a sub 'is pure' and call
> it with sufficiently constant arguments, it will be replaced at compile time
> with the result of the call, provided said call does not throw an exception.
> What constitutes "sufficiently constant" is not documented, poorly defined,
> and subject to change.

You said, "provided said call does not throw an exception".

So does that mean you have also promoted some runtime exceptions to compile time 
exceptions, or inlined the exception toss?

That would be useful.  You don't have to wait until runtime to know that the 
code is going to die unconditionally.

So constant folding can then work like this:

1.  If no exception will be thrown when using the constant arguments you have, 
replace the call with the result value as per usual.

2.  If an exception will certainly be thrown when using the constant arguments, 
then either:

2a.  Where you would otherwise have put the folded result, place a "fail"/etc.

2b.  Throw an exception at compile time.

Generally speaking, the more kinds of errors you can catch at compile time, the 
more reliable your program is.

-- Darren Duncan

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About