Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Revert "Use colon syntax for named parameters consistently"
This reverts commit 22f7192.
  • Loading branch information
lizmat committed Jul 15, 2015
1 parent 3ae9970 commit cadee02
Show file tree
Hide file tree
Showing 52 changed files with 425 additions and 438 deletions.
6 changes: 3 additions & 3 deletions src/core/AST.pm
Expand Up @@ -21,9 +21,9 @@ my class AST {
for @unquote_asts {
# TODO: find and report macro name
X::TypeCheck::Splice.new(
:got($_),
:expected(AST),
:action('unquote evaluation'),
got => $_,
expected => AST,
action => 'unquote evaluation',
).throw unless nqp::istype($_,AST);
nqp::push($pasts, nqp::getattr(nqp::decont($_), AST, '$!past'))
}
Expand Down
41 changes: 22 additions & 19 deletions src/core/Any.pm
Expand Up @@ -250,7 +250,7 @@ my class Any { # declared in BOOTSTRAP

proto method grep(|) is nodal { * }
multi method grep(Bool:D $t) is rw {
fail X::Match::Bool.new(:type<grep>);
fail X::Match::Bool.new( type => '.grep' );
}
multi method grep(Regex:D $test) is rw {
self.map({ next unless .match($test); $_ });
Expand All @@ -264,7 +264,7 @@ my class Any { # declared in BOOTSTRAP

proto method grep-index(|) is nodal { * }
multi method grep-index(Bool:D $t) is rw {
fail X::Match::Bool.new(:type<grep-index>);
fail X::Match::Bool.new( type => '.grep-index' );
}
multi method grep-index(Regex:D $test) {
my int $index = -1;
Expand Down Expand Up @@ -293,7 +293,7 @@ my class Any { # declared in BOOTSTRAP

proto method first(|) is nodal { * }
multi method first(Bool:D $t) is rw {
fail X::Match::Bool.new(:type<first>);
fail X::Match::Bool.new( type => '.first' );
}
multi method first(Regex:D $test) is rw {
self.map({ return-rw $_ if .match($test) });
Expand All @@ -310,7 +310,7 @@ my class Any { # declared in BOOTSTRAP

proto method first-index(|) is nodal { * }
multi method first-index(Bool:D $t) is rw {
fail X::Match::Bool.new(:type<first-index>);
fail X::Match::Bool.new( type => '.first-index' );
}
multi method first-index(Regex:D $test) {
my int $index = -1;
Expand Down Expand Up @@ -339,7 +339,7 @@ my class Any { # declared in BOOTSTRAP

proto method last-index(|) is nodal { * }
multi method last-index(Bool:D $t) is rw {
fail X::Match::Bool.new(:type<last-index>);
fail X::Match::Bool.new( type => '.last-index' );
}
multi method last-index(Regex:D $test) {
my $elems = self.elems;
Expand Down Expand Up @@ -469,7 +469,10 @@ my class Any { # declared in BOOTSTRAP
}
}
}
Range.new($min // Inf, $max // -Inf, :$excludes-min, :$excludes-max);
Range.new($min // Inf,
$max // -Inf,
:excludes-min($excludes-min),
:excludes-max($excludes-max));
}

method exists_pos(|c) is nodal {
Expand All @@ -490,7 +493,7 @@ my class Any { # declared in BOOTSTRAP
pos == 0;
}
multi method EXISTS-POS(Any:D: Num:D \pos) {
X::Item.new(:aggregate(self), :index(pos)).throw
X::Item.new(aggregate => self, index => pos).throw
if nqp::isnanorinf(pos);
self.AT-POS(nqp::unbox_i(pos.Int));
pos == 0;
Expand Down Expand Up @@ -521,7 +524,7 @@ my class Any { # declared in BOOTSTRAP
$v
}
multi method AT-POS(Any:U: Num:D \pos) is rw {
fail X::Item.new(:aggregate(self), :index(pos))
fail X::Item.new(aggregate => self, index => pos)
if nqp::isnanorinf(pos);
self.AT-POS(nqp::unbox_i(pos.Int));
}
Expand All @@ -540,7 +543,7 @@ my class Any { # declared in BOOTSTRAP
self;
}
multi method AT-POS(Any:D: Num:D \pos) is rw {
fail X::Item.new(:aggregate(self), :index(pos))
fail X::Item.new(aggregate => self, index => pos)
if nqp::isnanorinf(pos);
self.AT-POS(nqp::unbox_i(pos.Int));
}
Expand Down Expand Up @@ -574,7 +577,7 @@ my class Any { # declared in BOOTSTRAP
self.AT-POS(pos) = assignee; # defer < 0 check
}
multi method ASSIGN-POS(Any:D: Num:D \pos, Mu \assignee) {
fail X::Item.new(:aggregate(self), :index(pos))
fail X::Item.new(aggregate => self, index => pos)
if nqp::isnanorinf(pos);
self.AT-POS(nqp::unbox_i(pos.Int)) = assignee; # defer < 0 check
}
Expand All @@ -585,9 +588,9 @@ my class Any { # declared in BOOTSTRAP
die "Cannot use '{pos.^name}' as an index";
}

method all() is nodal { Junction.new(self.list, :type<all>) }
method any() is nodal { Junction.new(self.list, :type<any>) }
method one() is nodal { Junction.new(self.list, :type<one>) }
method all() is nodal { Junction.new(self.list, :type<all>) }
method any() is nodal { Junction.new(self.list, :type<any>) }
method one() is nodal { Junction.new(self.list, :type<one>) }
method none() is nodal { Junction.new(self.list, :type<none>) }

method at_key(|c) is rw is nodal {
Expand All @@ -614,7 +617,7 @@ my class Any { # declared in BOOTSTRAP

proto method BIND-KEY(|) is nodal { * }
multi method BIND-KEY(Any:D: \k, \v) is rw {
fail X::Bind.new(:target(self.^name));
fail X::Bind.new(target => self.^name);
}
multi method BIND-KEY(Any:U \SELF: $key, $BIND ) is rw {
SELF = Hash.new;
Expand Down Expand Up @@ -721,32 +724,32 @@ multi sub map(&code, Whatever) { (1..Inf).map(&code) }
proto sub grep(|) {*}
multi sub grep(Mu $test, @values) { @values.grep($test) }
multi sub grep(Mu $test, *@values) { @values.grep($test) }
multi sub grep(Bool:D $t, *@v) { fail X::Match::Bool.new(:type<grep> ) }
multi sub grep(Bool:D $t, *@v) { fail X::Match::Bool.new( type => 'grep' ) }

proto sub grep-index(|) {*}
multi sub grep-index(Mu $test, @values) { @values.grep-index($test) }
multi sub grep-index(Mu $test, *@values) { @values.grep-index($test) }
multi sub grep-index(Bool:D $t, *@v) {
fail X::Match::Bool.new(:type<grep-index>);
fail X::Match::Bool.new(type => 'grep-index');
}

proto sub first(|) {*}
multi sub first(Mu $test, @values) { @values.first($test) }
multi sub first(Mu $test, *@values) { @values.first($test) }
multi sub first(Bool:D $t, *@v) { fail X::Match::Bool.new(:type<first>) }
multi sub first(Bool:D $t, *@v) { fail X::Match::Bool.new( type => 'first' ) }

proto sub first-index(|) {*}
multi sub first-index(Mu $test, @values) { @values.first-index($test) }
multi sub first-index(Mu $test, *@values) { @values.first-index($test) }
multi sub first-index(Bool:D $t,*@v) {
fail X::Match::Bool.new(:type<first-index>);
fail X::Match::Bool.new(type => 'first-index');
}

proto sub last-index(|) {*}
multi sub last-index(Mu $test, @values) { @values.last-index($test) }
multi sub last-index(Mu $test, *@values) { @values.last-index($test) }
multi sub last-index(Bool:D $t, *@v) {
fail X::Match::Bool.new(:type<last-index>);
fail X::Match::Bool.new(type => 'last-index');
}

proto sub join(|) { * }
Expand Down
25 changes: 12 additions & 13 deletions src/core/Array.pm
Expand Up @@ -13,7 +13,7 @@ class Array { # declared in BOOTSTRAP
}

multi method AT-POS(Array:D: int \pos) is rw {
fail X::OutOfRange.new(:what<Index>,:got(pos),:range('0..Inf'))
fail X::OutOfRange.new(:what<Index>,:got(pos),:range<0..Inf>)
if nqp::islt_i(pos,0);
my Mu \items := nqp::p6listitems(self);
# hotpath check for element existence (RT #111848)
Expand All @@ -33,7 +33,7 @@ class Array { # declared in BOOTSTRAP
}
multi method AT-POS(Array:D: Int:D \pos) is rw {
my int $pos = nqp::unbox_i(pos.Int);
fail X::OutOfRange.new(:what<Index>,:got(pos),:range('0..Inf'))
fail X::OutOfRange.new(:what<Index>,:got(pos),:range<0..Inf>)
if nqp::islt_i($pos,0);
my Mu \items := nqp::p6listitems(self);
# hotpath check for element existence (RT #111848)
Expand All @@ -53,7 +53,7 @@ class Array { # declared in BOOTSTRAP
}

multi method ASSIGN-POS(Array:D: int \pos, Mu \assignee) is rw {
X::OutOfRange.new(:what<Index>,:got(pos),:range('0..Inf')).throw
X::OutOfRange.new(:what<Index>,:got(pos),:range<0..Inf>).throw
if nqp::islt_i(pos,0);
my \items := nqp::p6listitems(self);
nqp::existspos(items,pos)
Expand All @@ -64,7 +64,7 @@ class Array { # declared in BOOTSTRAP
}
multi method ASSIGN-POS(Array:D: Int:D \pos, Mu \assignee) is rw {
my int $pos = nqp::unbox_i(pos);
X::OutOfRange.new(:what<Index>,:got(pos),:range('0..Inf')).throw
X::OutOfRange.new(:what<Index>,:got(pos),:range<0..Inf>).throw
if nqp::islt_i($pos,0);
my \items := nqp::p6listitems(self);
nqp::existspos(items,$pos)
Expand All @@ -85,8 +85,7 @@ class Array { # declared in BOOTSTRAP
}

method DELETE-POS(\pos, :$SINK) {
fail X::Subscript::Negative.new(:index(pos),:type(self.WHAT))
if pos < 0;
fail X::Subscript::Negative.new(index => pos, type => self.WHAT) if pos < 0;

my $value := self.AT-POS(pos); # needed for reification
my $items := nqp::getattr(self,List,'$!items');
Expand Down Expand Up @@ -175,9 +174,9 @@ class Array { # declared in BOOTSTRAP
for @$list {
if $_ !~~ $of {
X::TypeCheck.new(
:operation<new>,
:expected($of),
:got($_),
operation => '.new',
expected => $of,
got => $_,
).throw;
}
}
Expand Down Expand Up @@ -272,7 +271,7 @@ class Array { # declared in BOOTSTRAP

multi method push(Array:D: \value) {
if nqp::iscont(value) || nqp::not_i(nqp::istype(value, Iterable)) && nqp::not_i(nqp::istype(value, Parcel)) {
fail X::Cannot::Infinite.new(:action('push to'))
fail X::Cannot::Infinite.new(:action('.push to'))
if self.infinite;
self.gimme(*);
nqp::p6listitems(self);
Expand All @@ -288,11 +287,11 @@ class Array { # declared in BOOTSTRAP
}

multi method push(Array:D: *@values) {
fail X::Cannot::Infinite.new(:action<push>, :what(self.^name))
fail X::Cannot::Infinite.new(:action<.push>, :what(self.^name))
if @values.infinite;
nqp::p6listitems(self);
my $elems = self.gimme(*);
fail X::Cannot::Infinite.new(:action('push to'))
fail X::Cannot::Infinite.new(:action('.push to'))
if self.infinite;

# push is always eager
Expand All @@ -309,7 +308,7 @@ class Array { # declared in BOOTSTRAP

multi method unshift(Array:D: \value) {
if nqp::iscont(value) || nqp::not_i(nqp::istype(value, Iterable)) && nqp::not_i(nqp::istype(value, Parcel)) {
fail X::Cannot::Infinite.new(:action('push to'))
fail X::Cannot::Infinite.new(:action<.push to>)
if self.infinite;
self.gimme(*);
nqp::p6listitems(self);
Expand Down
2 changes: 1 addition & 1 deletion src/core/Backtrace.pm
Expand Up @@ -200,7 +200,7 @@ my class Backtrace {
my ($target_idx) = @outer_callers.keys.grep({self.AT-POS($i).code.^isa(Routine)});
$target_idx ||= @outer_callers[0] || $i;
my $current = self.AT-POS($target_idx);
@frames.push: $current.clone(:line($prev.line));
@frames.push: $current.clone(line => $prev.line);
$i = $target_idx;
}
last if $oneline;
Expand Down
8 changes: 4 additions & 4 deletions src/core/Bag.pm
Expand Up @@ -17,10 +17,10 @@ my class Bag does Baggy {
%!elems.values.map: { Enum.new(:key(.value),:value(.key)) };
}
multi method grab(Bag:D: $count?) {
X::Immutable.new(:method<grab>, :typename(self.^name)).throw;
X::Immutable.new( method => 'grab', typename => self.^name ).throw;
}
multi method grabpairs(Bag:D: $count?) {
X::Immutable.new(:method<grabpairs>, :typename(self.^name)).throw;
X::Immutable.new( method => 'grabpairs', typename => self.^name ).throw;
}

method Bag { self }
Expand All @@ -33,10 +33,10 @@ my class Bag does Baggy {
nqp::istype(v,Pair) ?? v.value !! 0;
}
multi method ASSIGN-KEY(Bag:D: \k,\v) {
X::Assignment::RO.new(:typename(self.^name)).throw;
X::Assignment::RO.new(typename => self.^name).throw;
}
multi method DELETE-KEY(Bag:D: \k) {
X::Immutable.new(:method<DELETE-KEY>, :typename(self.^name)).throw;
X::Immutable.new(method => 'DELETE-KEY', typename => self.^name).throw;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/core/Baggy.pm
Expand Up @@ -229,7 +229,7 @@ my role Baggy does QuantHash {

proto method classify-list(|) { * }
multi method classify-list( &test, *@list ) {
fail X::Cannot::Infinite.new(:action<classify>) if @list.infinite;
fail X::Cannot::Infinite.new(:action<.classify>) if @list.infinite;
if @list {

# multi-level classify
Expand Down Expand Up @@ -259,7 +259,7 @@ my role Baggy does QuantHash {

proto method categorize-list(|) { * }
multi method categorize-list( &test, *@list ) {
fail X::Cannot::Infinite.new(:action<categorize>) if @list.infinite;
fail X::Cannot::Infinite.new(:action<.categorize>) if @list.infinite;
if @list {

# multi-level categorize
Expand Down
37 changes: 18 additions & 19 deletions src/core/Buf.pm
Expand Up @@ -60,9 +60,9 @@ my role Blob[::T = uint8] does Positional[T] does Stringy is repr('VMArray') is
method bytes(Blob:D:) {
ceiling(self.elems * ::T.^nativesize / 8);
}
method chars(Blob:D:) { X::Buf::AsStr.new(:method<chars> ).throw }
multi method Str(Blob:D:) { X::Buf::AsStr.new(:method<Str> ).throw }
multi method Stringy(Blob:D:) { X::Buf::AsStr.new(:method<Stringy>).throw }
method chars(Blob:D:) { X::Buf::AsStr.new(method => 'chars').throw }
multi method Str(Blob:D:) { X::Buf::AsStr.new(method => 'Str' ).throw }
multi method Stringy(Blob:D:) { X::Buf::AsStr.new(method => 'Stringy' ).throw }

method Numeric(Blob:D:) { self.elems }
method Int(Blob:D:) { self.elems }
Expand Down Expand Up @@ -91,35 +91,35 @@ my role Blob[::T = uint8] does Positional[T] does Stringy is repr('VMArray') is

method subbuf(Blob:D: $from = 0, $len is copy = self.elems - $from) {

if $len < 0 {
if ($len < 0) {
X::OutOfRange.new(
:what('Length element to subbuf'),
:got($len),
:range("0..{self.elems}"),
).fail;
what => "Len element to subbuf",
got => $len,
range => (0..self.elems)).fail;
}


my $ret := nqp::create(self);

my int $ifrom = nqp::unbox_i(
nqp::istype($from, Callable)
?? $from(nqp::p6box_i(self.elems))
!! $from.Int);

if $ifrom < 0 {
if ($ifrom < 0) {
X::OutOfRange.new(
:what('From argument to subbuf'),
:got($from.gist),
:range("0..{self.elems}"),
:comment("use *$ifrom if you want to index relative to the end"),
what => 'From argument to subbuf',
got => $from.gist,
range => (0..self.elems),
comment => "use *{$ifrom} if you want to index relative to the end"
).fail;
}

if $ifrom > self.elems {
if ($ifrom > self.elems) {
X::OutOfRange.new(
:what('From argument to subbuf'),
:got($from.gist),
:range("0..{self.elems}"),
what => 'From argument to subbuf',
got => $from.gist,
range => (0..self.elems),
).fail;
}

Expand Down Expand Up @@ -317,8 +317,7 @@ multi sub pack(Str $template, *@items) {
$amount = 1;
}
for (@$data, 0x20 xx *).flat[^$amount] -> $byte {
X::Buf::Pack::NonASCII.new(:char($byte.chr)).throw
if $byte > 0x7f;
X::Buf::Pack::NonASCII.new(:char($byte.chr)).throw if $byte > 0x7f;
@bytes.push: $byte;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/CallFrame.pm
Expand Up @@ -31,12 +31,12 @@ my class CallFrame {
}

method callframe(Int $level = 0) {
X::NYI.new(:feature<Callframe.callframe>).throw;
X::NYI.new(feature => 'Callframe.callframe').throw;
}
}

sub callframe(Int $level = 0) {
CallFrame.new(:level($level + 1));
CallFrame.new(level => ($level + 1));
}

# vim: ft=perl6 expandtab sw=4

0 comments on commit cadee02

Please sign in to comment.