Google Groups Home
Help | Sign in
Blocks, continuations and eval()
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  15 messages - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Wolverian  
View profile
 More options Apr 8 2005, 10:03 am
Newsgroups: perl.perl6.language
From: w...@sci.fi (Wolverian)
Date: Fri, 8 Apr 2005 17:03:11 +0300
Local: Fri, Apr 8 2005 10:03 am
Subject: Blocks, continuations and eval()

Hi,

(I'm sorry if this topic has already been discussed.)

one day a friend asked if Perl 5 had a REPL facility.
(Read-Eval-Print-Loop). I told him it has perl -de0, which is different
in that it does not preserve the lexical scope across evaluated lines.
This is because eval STRING creates its own scope, in which the string
is then evaluated.

You can hack around this with a recursive eval(), which will eventually
blow the stack. I wrote a short module to do this, but never released
it. Have others done this? :)

To get to the real topic:

In Perl 6, the generic solution to fix this (if one wants to fix it)
seems, to me, to be to add a .eval method to objects that represent
scopes. I'm not sure if scopes are first class values in Perl 6. Are
they? How do you get the current scope as an object? Are scopes just
Code objects?

On #perl6, theorbtwo wasn't sure if .eval should be a method on coderefs
or blocks. Is there a difference between the two? I always hated this
about Ruby; there seems to be no practical value to the separation.

Also, are blocks/coderefs/scopes continuations? Should .eval be a method
in Continuation?

Thanks,

--
wolverian

  signature.asc
< 1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
David Storrs  
View profile
 More options Apr 8 2005, 11:35 am
Newsgroups: perl.perl6.language
From: dsto...@dstorrs.com (David Storrs)
Date: Fri, 8 Apr 2005 08:35:30 -0700
Local: Fri, Apr 8 2005 11:35 am
Subject: Re: Blocks, continuations and eval()

On Fri, Apr 08, 2005 at 05:03:11PM +0300, wolverian wrote:

Hi wolverian,

> one day a friend asked if Perl 5 had a REPL facility.
> (Read-Eval-Print-Loop). I told him it has perl -de0, which is different
> [...]
> In Perl 6, the generic solution to fix this (if one wants to fix it)
> seems, to me, to be to add a .eval method to objects that represent
> scopes. I'm not sure if scopes are first class values in Perl 6. Are
> they? How do you get the current scope as an object? Are scopes just
> Code objects?

I'm unclear on what you're looking for.  Are you trying to get a way
to do interactive coding in P6?  Or the ability to "freeze" a scope
and execute it later?  Or something else?

--Dks

--
dsto...@dstorrs.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
MrJoltCola  
View profile
 More options Apr 8 2005, 12:18 pm
Newsgroups: perl.perl6.language
From: mrjoltc...@mindspring.com (MrJoltCola)
Date: Fri, 08 Apr 2005 12:18:45 -0400
Local: Fri, Apr 8 2005 12:18 pm
Subject: Re: Blocks, continuations and eval()
At 10:03 AM 4/8/2005, wolverian wrote:

>To get to the real topic:

>In Perl 6, the generic solution to fix this (if one wants to fix it)
>seems, to me, to be to add a .eval method to objects that represent
>scopes. I'm not sure if scopes are first class values in Perl 6. Are
>they? How do you get the current scope as an object? Are scopes just
>Code objects?

>On #perl6, theorbtwo wasn't sure if .eval should be a method on coderefs
>or blocks. Is there a difference between the two? I always hated this
>about Ruby; there seems to be no practical value to the separation.

>Also, are blocks/coderefs/scopes continuations? Should .eval be a method
>in Continuation?

I'm having a bit of trouble following you, but I can tell you that the VM
portion
treats continuations as well as lexical scopes or pads as first class Parrot
objects (or PMCs).

I cannot say how much Perl6 will expose to the high level language.

Can you tell me what your idea of a "scope" is? I'm thinking a
continuation, and if that is what you are thinking, I'm thinking the
answer to your question is yes.

-Melvin


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wolverian  
View profile
 More options Apr 8 2005, 12:00 pm
Newsgroups: perl.perl6.language
From: w...@sci.fi (Wolverian)
Date: Fri, 8 Apr 2005 19:00:40 +0300
Local: Fri, Apr 8 2005 12:00 pm
Subject: Re: Blocks, continuations and eval()

On Fri, Apr 08, 2005 at 08:35:30AM -0700, David Storrs wrote:
> I'm unclear on what you're looking for.  Are you trying to get a way
> to do interactive coding in P6?  Or the ability to "freeze" a scope
> and execute it later?  Or something else?

Neither in itself. I'm looking for a way to refer to scopes
programmatically. I'm also asking if they are continuations, or blocks,
or coderefs, or are those all the same?

The two things you mention are effects of being able to refer to scopes
in such a fashion. I do want both, but the real question isn't if they
are possible, but about what blocks, coderefs and scopes are.

I'm sorry if I was unclear. I probably should have spent more time
writing the post. :)

> --Dks

--
wolverian

  signature.asc
< 1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wolverian  
View profile
 More options Apr 8 2005, 12:41 pm
Newsgroups: perl.perl6.language
From: w...@sci.fi (Wolverian)
Date: Fri, 8 Apr 2005 19:41:40 +0300
Local: Fri, Apr 8 2005 12:41 pm
Subject: Re: Blocks, continuations and eval()

On Fri, Apr 08, 2005 at 12:18:45PM -0400, MrJoltCola wrote:
> I cannot say how much Perl6 will expose to the high level language.

That is what I'm wondering about. I'm sorry I was so unclear.

> Can you tell me what your idea of a "scope" is? I'm thinking a
> continuation, and if that is what you are thinking, I'm thinking the
> answer to your question is yes.

Yes. I want to know how Perl 6 exposes continuations, and how to get one
for, say, the current lexical scope, and if it has a method on it that
lets me evaluate code in that context (or some other way to do that).

> -Melvin

--
wolverian

  signature.asc
< 1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Piers Cawley  
View profile
 More options Apr 12 2005, 6:36 am
Newsgroups: perl.perl6.language
From: pdcaw...@bofh.org.uk (Piers Cawley)
Date: Tue, 12 Apr 2005 11:36:02 +0100
Local: Tues, Apr 12 2005 6:36 am
Subject: Re: Blocks, continuations and eval()

wolverian <w...@sci.fi> writes:
> On Fri, Apr 08, 2005 at 12:18:45PM -0400, MrJoltCola wrote:
>> I cannot say how much Perl6 will expose to the high level language.

> That is what I'm wondering about. I'm sorry I was so unclear.

>> Can you tell me what your idea of a "scope" is? I'm thinking a
>> continuation, and if that is what you are thinking, I'm thinking the
>> answer to your question is yes.

> Yes. I want to know how Perl 6 exposes continuations, and how to get one
> for, say, the current lexical scope, and if it has a method on it that
> lets me evaluate code in that context (or some other way to do that).

As I understand what Larry's said before. Out of the box, it
doesn't. Apparently we're going to have to descend to Parrot to write
evalcc/letcc/your-preferred-continuation-idiom equivalent.

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile
 More options Apr 12 2005, 7:17 am
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Tue, 12 Apr 2005 04:17:56 -0700
Local: Tues, Apr 12 2005 7:17 am
Subject: Re: Blocks, continuations and eval()
On Tue, Apr 12, 2005 at 11:36:02AM +0100, Piers Cawley wrote:
: wolverian <w...@sci.fi> writes:

:
: > On Fri, Apr 08, 2005 at 12:18:45PM -0400, MrJoltCola wrote:
: >> I cannot say how much Perl6 will expose to the high level language.
: >
: > That is what I'm wondering about. I'm sorry I was so unclear.
: >
: >> Can you tell me what your idea of a "scope" is? I'm thinking a
: >> continuation, and if that is what you are thinking, I'm thinking the
: >> answer to your question is yes.
: >
: > Yes. I want to know how Perl 6 exposes continuations, and how to get one
: > for, say, the current lexical scope, and if it has a method on it that
: > lets me evaluate code in that context (or some other way to do that).
:
: As I understand what Larry's said before. Out of the box, it
: doesn't. Apparently we're going to have to descend to Parrot to write
: evalcc/letcc/your-preferred-continuation-idiom equivalent.

We'll make continuations available in Perl for people who ask for
them specially, but we're not going to leave them sitting out in the
open where some poor benighted pilgrim might trip over them unawares.

Larry


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Piers Cawley  
View profile
 More options Apr 12 2005, 1:35 pm
Newsgroups: perl.perl6.language
From: pdcaw...@bofh.org.uk (Piers Cawley)
Date: Tue, 12 Apr 2005 18:35:19 +0100
Local: Tues, Apr 12 2005 1:35 pm
Subject: Re: Blocks, continuations and eval()

Oh goody! Presumably we're initially talking of a simple
'call_with_current_continuation'?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Wolverian  
View profile
 More options Apr 21 2005, 9:30 am
Newsgroups: perl.perl6.language
From: w...@sci.fi (Wolverian)
Date: Thu, 21 Apr 2005 16:30:07 +0300
Local: Thurs, Apr 21 2005 9:30 am
Subject: Re: Blocks, continuations and eval()

On Tue, Apr 12, 2005 at 04:17:56AM -0700, Larry Wall wrote:
> We'll make continuations available in Perl for people who ask for
> them specially, but we're not going to leave them sitting out in the
> open where some poor benighted pilgrim might trip over them unawares.

Sorry for replying so late, but I missed your reply somehow. I just want
to ask a little clarification on this; exactly what kind of hiding are
you considering for continuations? That is, do you just mean that there
will not be a 'call/cc' primitive by default in the global namespace?
I'm fine with that, as that's just one method of capturing the calling
continuation.

> Larry

--
wolverian

  signature.asc
< 1K Download

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Larry Wall  
View profile
 More options Apr 21 2005, 11:36 am
Newsgroups: perl.perl6.language
From: la...@wall.org (Larry Wall)
Date: Thu, 21 Apr 2005 08:36:28 -0700
Local: Thurs, Apr 21 2005 11:36 am
Subject: Re: Blocks, continuations and eval()
On Thu, Apr 21, 2005 at 04:30:07PM +0300, wolverian wrote:

: On Tue, Apr 12, 2005 at 04:17:56AM -0700, Larry Wall wrote:
: > We'll make continuations available in Perl for people who ask for
: > them specially, but we're not going to leave them sitting out in the
: > open where some poor benighted pilgrim might trip over them unawares.
:
: Sorry for replying so late, but I missed your reply somehow. I just want
: to ask a little clarification on this; exactly what kind of hiding are
: you considering for continuations? That is, do you just mean that there
: will not be a 'call/cc' primitive by default in the global namespace?
: I'm fine with that, as that's just one method of capturing the calling
: continuation.

I suspect it's just something like

    use Continuations;

at the top to enable the low-level interface.  There would be no
restriction on using continuation semantics provided by other modules,
because then the "use" of that other module implies whatever form
of continuation it provides.

My concern is primarily the reader of the code, who needs some kind
of warning that one can get sliced while juggling sharp knives.  If
we were willing to be a little more Ada-like, we'd make it a shouted
warning:

    use CONTINUATIONS;

Hmm, maybe that's not such a bad policy.  I wonder what other "dangerous"
modules we might have.  Ada had UNCHECKED_TYPE_CONVERSION, for instance.

Larry


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nigel Sandever  
View profile
 More options Apr 21 2005, 12:09 pm
Newsgroups: perl.perl6.language
From: nigelsande...@btconnect.com (Nigel Sandever)
Date: Thu, 21 Apr 2005 16:09:21 GMT
Local: Thurs, Apr 21 2005 12:09 pm
Subject: Re: Blocks, continuations and eval()

On Thu, 21 Apr 2005 08:36:28 -0700, la...@wall.org (Larry Wall) wrote:

> Hmm, maybe that's not such a bad policy.  I wonder what other "dangerous"
> modules we might have.  Ada had UNCHECKED_TYPE_CONVERSION, for instance.

How about
        use RE_EVAL; # or should that be REALLY_EVIL?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Stéphane Payrard  
View profile
 More options Apr 22 2005, 7:15 am
Newsgroups: perl.perl6.language
From: s...@payrard.net (Stéphane Payrard)
Date: Fri, 22 Apr 2005 13:15:35 +0200
Local: Fri, Apr 22 2005 7:15 am
Subject: Re: Blocks, continuations and eval()
Hi,

I am making a presentation about Perl6 this week end.  My point will
be: the next generation of applicative languages will be scripting
languages because they have come of age.

Alternatives don't cut it anymore. Indeed C and C++ are memory
allocation nightmare; Java and C# don't have read-eval loop, a
necessary condition for rapid learning and development.  Functional
languages like haskell or ocaml are very powerful but needs massive
wetware reconfiguration to get used to the syntax and semantic.

So I will make do a presentation of Perl6 and Parrot features to make
my point about upcoming scripting languages.

I have a few questions inspired by my recently acquired  knowledge
about functional languages. Perl6 being the ultimate syncretist
language, I wonder if some functional features will make it
into Perl6. I know we already got currying.

A very nice feature of Haskell and *ml is the possibility to define
complex datastructures types and the control flow that manipulate
these structures: constructors and pattern matching.  With these
languages, in a very deep sense, control flow is pattern matching. Can
we expect Perl6 to propose something similar?

If yes,