Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support using $? variables and implement $?PROGRAM #698

Closed
p6rt opened this issue Feb 14, 2009 · 6 comments
Closed

Support using $? variables and implement $?PROGRAM #698

p6rt opened this issue Feb 14, 2009 · 6 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Feb 14, 2009

Migrated from rt.perl.org#63228 (status was 'rejected')

Searchable as RT63228$

@p6rt
Copy link
Author

p6rt commented Feb 14, 2009

From @chrisdolan

This patch adds support for '?' twigil variables to actions.pm and
declares the $?PROGRAM read-only global variable in !UNIT_START. The
value stored in that variable is first argument to Rakudo (e.g.
'prog.pl' or '-e') which previously was dropped on the floor when
creating @​*ARGS.

  git pull git​://github.com/chrisdolan/rakudo.git program-name

t/spec/S02-magicals/progname.t updated to test this in r25324

@p6rt
Copy link
Author

p6rt commented Feb 14, 2009

From @chrisdolan

0001-Support-using-variables-and-implement-PROGRAM.patch
From df1ec6e81258e8af6ea6ca0e1654b075f42ae781 Mon Sep 17 00:00:00 2001
From: Chris Dolan <chris@chrisdolan.net>
Date: Fri, 13 Feb 2009 23:00:57 -0600
Subject: [PATCH] Support using $? variables and implement $?PROGRAM

---
 src/builtins/guts.pir |    7 ++++++-
 src/parser/actions.pm |    6 ++++++
 2 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/src/builtins/guts.pir b/src/builtins/guts.pir
index 69cd7d0..1f737ad 100644
--- a/src/builtins/guts.pir
+++ b/src/builtins/guts.pir
@@ -312,8 +312,13 @@ first). So for now we just transform multis in user code like this.
 
   start_main:
     ## We're running as main program
-    ## Remove program argument (0) and set up @ARGS global
+
+    ## Remove program argument ($?PROGRAM) and set up @ARGS global
     $P0 = shift args
+    $P1 = get_hll_global [ "Bool" ], "True"
+    setprop $P0, "readonly", $P1
+    set_hll_global "$?PROGRAM", $P0
+
     args = args.'Array'()
     set_hll_global '@ARGS', args
     ## run unitmain
diff --git a/src/parser/actions.pm b/src/parser/actions.pm
index 7f1f339..9e0fb50 100644
--- a/src/parser/actions.pm
+++ b/src/parser/actions.pm
@@ -1972,6 +1972,12 @@ method variable($/, $key) {
             $var.viviself( container_itype($sigil) );
         }
 
+        # If it has a '?' twigil, it's a compiler hint var.
+        if $twigil eq '?' {
+            $var.namespace(@ns);
+            $var.scope('package');
+        }
+
         ## @_ and %_ add a slurpy param to the block
         if $varname eq '@_' || $varname eq '%_' {
             unless $?BLOCK.symbol($varname) {
-- 
1.6.1

@p6rt
Copy link
Author

p6rt commented Feb 14, 2009

From @chrisdolan

On Fri Feb 13 21​:14​:59 2009, chris@​chrisdolan.net wrote​:

This patch adds support for '?' twigil variables to actions.pm and
declares the $?PROGRAM read-only global variable in !UNIT_START. The
value stored in that variable is first argument to Rakudo (e.g.
'prog.pl' or '-e') which previously was dropped on the floor when
creating @​*ARGS.

git pull git​://github.com/chrisdolan/rakudo.git program-name

t/spec/S02-magicals/progname.t updated to test this in r25324

Larry changed the spec 5 minutes after I submitted this, so $?PROGRAM is
no longer correct. I think the actions.pm half of the patch is still
right, though.

@p6rt
Copy link
Author

p6rt commented Feb 14, 2009

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 23, 2011

From @coke

On Fri Feb 13 21​:50​:40 2009, chrisdolan wrote​:

On Fri Feb 13 21​:14​:59 2009, chris@​chrisdolan.net wrote​:

This patch adds support for '?' twigil variables to actions.pm and
declares the $?PROGRAM read-only global variable in !UNIT_START. The
value stored in that variable is first argument to Rakudo (e.g.
'prog.pl' or '-e') which previously was dropped on the floor when
creating @​*ARGS.

git pull git​://github.com/chrisdolan/rakudo.git program-name

t/spec/S02-magicals/progname.t updated to test this in r25324

Larry changed the spec 5 minutes after I submitted this, so $?PROGRAM is
no longer correct. I think the actions.pm half of the patch is still
right, though.

Very sorry, this patch seems to have gotten lost in RT, and even the part
that wasn't specced out from under you no longer applies.

Thanks for the patch, we'll try to get to them faster in the future!

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Sep 23, 2011

@coke - Status changed from 'open' to 'rejected'

@p6rt p6rt closed this as completed Sep 23, 2011
@p6rt p6rt added the patch label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant