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

perl6 - sub/hash syntax #1996

Closed
p6rt opened this issue Aug 1, 2010 · 6 comments
Closed

perl6 - sub/hash syntax #1996

p6rt opened this issue Aug 1, 2010 · 6 comments

Comments

@p6rt
Copy link

p6rt commented Aug 1, 2010

Migrated from rt.perl.org#76896 (status was 'resolved')

Searchable as RT76896$

@p6rt
Copy link
Author

p6rt commented Aug 1, 2010

From ekkehorner@googlemail.com

The script​:

  use v6;

  my %fs = ();

  %fs{ lc( 'A' ) } = &fa;
  sub fa() {
  return 'fa called.';
  }

  ;

  %fs{ lc( 'B' ) } = &fb;
  sub fb() {
  return 'fb called.';
  }

  my $fn = lc( @​*ARGS[ 0 ] || 'A' );
  printf "%s\n", %fs{ $fn }();

  exit( 0 );

works as expected​:

  PARROT E​:\proj\xpl\perl6\archive\00
  perl6 -v

  This is Rakudo Perl 6, version 2010.07-47-g9fd5eaa built on parrot 2.6.0

  Copyright 2008-2010, The Perl Foundation

  PARROT E​:\proj\xpl\perl6\archive\00
  perl6 xpl02.pl6 B
  fb called.

but if I delete the lonesome ; in line 10, I get this error​:

  PARROT E​:\proj\xpl\perl6\archive\00
  perl6 xpl02.pl6 A
  Could not find sub &fs
  in main program body at line 12​:xpl02.pl6

(I asked about this in de.comp.lang.perl.misc and was advised to submit a
bug report.)

@p6rt
Copy link
Author

p6rt commented Aug 12, 2010

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

@p6rt
Copy link
Author

p6rt commented Oct 8, 2011

From @coke

Still happens in rakudo 88c5a5.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Apr 5, 2013

From @coke

On Sun Aug 01 07​:19​:06 2010, ekkehorner@​googlemail.com wrote​:

The script​:

use v6;

my %fs = \(\);

%fs\{ lc\( 'A' \) \} = &fa;
sub fa\(\) \{
  return 'fa called\.';
\}

;

%fs\{ lc\( 'B' \) \} = &fb;
sub fb\(\) \{
  return 'fb called\.';
\}

my $fn = lc\( @​\*ARGS\[ 0 \] || 'A' \);
printf "%s\\n", %fs\{ $fn \}\(\);

exit\( 0 \);

works as expected​:

PARROT E​:\proj\xpl\perl6\archive\00
perl6 -v

This is Rakudo Perl 6, version 2010.07-47-g9fd5eaa built on parrot 2.6.0

Copyright 2008-2010, The Perl Foundation

PARROT E​:\proj\xpl\perl6\archive\00
perl6 xpl02.pl6 B
fb called.

but if I delete the lonesome ; in line 10, I get this error​:

PARROT E​:\proj\xpl\perl6\archive\00
perl6 xpl02.pl6 A
Could not find sub &fs
in main program body at line 12​:xpl02.pl6

(I asked about this in de.comp.lang.perl.misc and was advised to submit a
bug report.)

This works now - can be closed with a test.

--
Will "Coke" Coleda

@p6rt
Copy link
Author

p6rt commented Aug 25, 2013

From dmol@gmx.com

Test added by commit
Raku/roast@c15d965
08606

@p6rt
Copy link
Author

p6rt commented Dec 23, 2013

@timo - Status changed from 'open' to 'resolved'

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

No branches or pull requests

1 participant