Skip to content

Commit

Permalink
Moves EVAL as method back to Cool
Browse files Browse the repository at this point in the history
Also eliminates implementation details from EVAL. Closes #2822
  • Loading branch information
JJ committed May 22, 2019
1 parent 94ff45f commit 649b9e9
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
11 changes: 11 additions & 0 deletions doc/Type/Cool.pod6
Expand Up @@ -142,6 +142,17 @@ imaginary part negated).
say (1+2i).conj; # OUTPUT: «1-2i␤»
=head2 routine EVAL
Defined as:
=for code :method
method EVAL(*%_)
It calls the L<subroutine form|/type/independent-routines#sub_mkdir> with the
invocant as the first argument, C<$code>, passing along named args, if any.
=head2 routine sqrt
Defined as:
Expand Down
15 changes: 5 additions & 10 deletions doc/Type/independent-routines.pod6
Expand Up @@ -12,23 +12,18 @@ actually attached to any particular class or role.
Defined as:
=begin code :method
method EVAL(*%_)
=end code
=begin code :method
proto sub EVAL($code is copy where Blob|Cool|Callable, Str() :$lang = 'perl6',
proto sub EVAL($code where Blob|Cool|Callable, Str() :$lang = 'perl6',
PseudoStash :$context, *%n)
=end code
=begin code :method
multi sub EVAL($code, Str :$lang where { ($lang // '') eq 'Perl5' },
PseudoStash :$context)
=end code
If it is invoked as a method, it calls the subroutine form with
invocant as the first argument, C<$code>, passing along named args, if any; this
coerces L<Cool|/type/Cool> C<$code> to L<Str|/type/Str>. If C<$code> is a
L<Blob|/type/Blob>, it'll be processed using the same encoding as the C<$lang>
compiler would: for C<perl6> C<$lang>, uses C<utf-8>; for C<Perl5>, processes
using the same rules as C<perl>.
This routine coerces L<Cool|/type/Cool> C<$code> to L<Str|/type/Str>. If
C<$code> is a L<Blob|/type/Blob>, it'll be processed using the same encoding as
the C<$lang> compiler would: for C<perl6> C<$lang>, uses C<utf-8>; for C<Perl5>,
processes using the same rules as C<perl>.
This works as-is with a literal string parameter. More complex input,
such as a variable or string with embedded code, is illegal by default.
Expand Down

0 comments on commit 649b9e9

Please sign in to comment.