Nil ?

2018-09-11 Thread ToddAndMargo
What am, I missing? $ p6 'my $x; if $x =:= Nil { say "Nil" } else { say "Not Nil"; };' Not Nil $ p6 'my $x = Nil; if $x =:= Nil { say "Nil" } else { say "Not Nil"; };' Not Nil

nil mystery

2018-04-29 Thread ToddAndMargo
Hi All, These two throw an operating on a "Nil" error: $PartsStr ~= "$PartNo"; $PartsStr ~= "{$PartNo}"; But this does not: $PartsStr ~= "{$PartNo}" ~ ""; And this does not either: $PartsStr ~= "abcde"; Huh? Many

Re: Nil ?

2018-09-12 Thread Simon Proctor
If you don't define the type of a Scalar and don't assign to it you'll have an undefined Any (the Parent class of all the other types). If you assign Nil to it then you have the same effect. You can make $x to be Nil by iether casting it : my Nil $x; or binding it to Nil; m

Re: Nil ?

2018-09-12 Thread Elizabeth Mattijsen
Also: my $a is default(Nil); > On 12 Sep 2018, at 09:25, Simon Proctor wrote: > > If you don't define the type of a Scalar and don't assign to it you'll have > an undefined Any (the Parent class of all the other types). If you assign Nil > to it then you have

Re: Nil ?

2018-09-12 Thread Simon Proctor
O learn something new everyday :) On Wed, 12 Sep 2018 at 08:46 Elizabeth Mattijsen wrote: > Also: > > my $a is default(Nil); > > > On 12 Sep 2018, at 09:25, Simon Proctor wrote: > > > > If you don't define the type of a Scalar and don't assign t

Re: Nil ?

2018-09-12 Thread JJ Merelo
When you assign Nil to a string or any object, it takes its default value. Cheers El mié., 12 sept. 2018 a las 10:23, Simon Proctor () escribió: > O learn something new everyday :) > > On Wed, 12 Sep 2018 at 08:46 Elizabeth Mattijsen wrote: > >> Also: >>

Re: Nil ?

2018-09-12 Thread Larry Wall
Basically, ignore any advice to treat Nil as a normal value, because it really is intended to represent the *absence* of a value as much as possible. It's a bit like the way solid-state electronics treats "holes" as if they were real particles, and gets away with it much of the ti

Re: Nil ?

2018-09-13 Thread ToddAndMargo
On 09/12/2018 10:09 AM, Larry Wall wrote: Basically, ignore any advice to treat Nil as a normal value, because it really is intended to represent the *absence* of a value as much as possible. It's a bit like the way solid-state electronics treats "holes" as if they were real part

Re: Nil ?

2018-09-13 Thread Elizabeth Mattijsen
> On 13 Sep 2018, at 20:47, ToddAndMargo wrote: > On 09/12/2018 10:09 AM, Larry Wall wrote: >> Basically, ignore any advice to treat Nil as a normal value, because >> it really is intended to represent the *absence* of a value as much as >> possible. It's a

Re: Nil ?

2018-09-13 Thread ToddAndMargo
On 09/13/2018 12:29 PM, Elizabeth Mattijsen wrote: On 13 Sep 2018, at 20:47, ToddAndMargo wrote: On 09/12/2018 10:09 AM, Larry Wall wrote: Basically, ignore any advice to treat Nil as a normal value, because it really is intended to represent the *absence* of a value as much as possible. It&#

Re: Nil ?

2018-09-13 Thread Elizabeth Mattijsen
> On 13 Sep 2018, at 23:21, ToddAndMargo wrote: > On 09/13/2018 12:29 PM, Elizabeth Mattijsen wrote: >>> On 13 Sep 2018, at 20:47, ToddAndMargo wrote: >>> On 09/12/2018 10:09 AM, Larry Wall wrote: >>>> Basically, ignore any advice to treat Nil as a nor

Re: Nil ?

2018-09-13 Thread Todd Chester
On 09/13/2018 02:24 PM, Elizabeth Mattijsen wrote: On 13 Sep 2018, at 23:21, ToddAndMargo wrote: $ p6 'my $x="\na\nb\nc\n"; for ( split "\n", $x ) -> $i {print "<$i>\n"};' <> <> with beginning and ending new lines. FWIW, a more Perl6ish way would be: $ p6 'my $x="\na\nb\nc\n"; for $

Re: nil mystery

2018-04-29 Thread Andrew Kirkpatrick
There is not enough context to answer or even reproduce the problem - how are the variables declared and what values do they have just prior to this line? Also, what version of rakudo? On 30 April 2018 at 11:29, ToddAndMargo wrote: > Hi All, > > These two throw an operating on a &q

Re: nil mystery

2018-04-29 Thread ToddAndMargo
, These two throw an operating on a "Nil" error: $PartsStr ~= "$PartNo"; $PartsStr ~= "{$PartNo}"; But this does not: $PartsStr ~= "{$PartNo}" ~ ""; And this does not either: $PartsStr ~= "abcde"; Huh? Many thanks

Re: nil mystery

2018-04-29 Thread ToddAndMargo
On 04/29/2018 10:12 PM, ToddAndMargo wrote: On 04/29/2018 09:32 PM, Andrew Kirkpatrick wrote: There is not enough context to answer or even reproduce the problem - how are the variables declared and what values do they have just prior to this line? Some simpler examples: $ perl6 -e 'my $x="ab

Re: nil mystery

2018-04-30 Thread ToddAndMargo
On Sun, Apr 29, 2018 at 10:20:48PM -0700, ToddAndMargo wrote: On 04/29/2018 10:12 PM, ToddAndMargo wrote: On 04/29/2018 09:32 PM, Andrew Kirkpatrick wrote: There is not enough context to answer or even reproduce the problem - how are the variables declared and what values do they have just pr

Re: nil mystery

2018-04-30 Thread Andrew Kirkpatrick
The original error you quoted was about use of Nil. I couldn't reproduce this by assigning Nil to a variable, turns out that's because such an assignment is specified to set the variable to the default value of the type of the variable. my $x = Nil gives (Any), my Str $y = Nil gives

Re: nil mystery

2018-04-30 Thread ToddAndMargo
On 04/30/2018 05:20 PM, Andrew Kirkpatrick wrote: I couldn't reproduce this by assigning Nil to a variable Well as it transpires, when I tested the {$x} version, I forgot to press "save". Also, a one liner operated differently than a program. And to top things off, when read

Need help with Nil values

2016-02-22 Thread TS xx
Dear perl 6 users, I am trying to pass a Nil value to a method new of a class that expects a Str. The method new will assign this Nil value to a Str member variable. Then, this value will change during runtime. At the moment I am getting this error: Type check failed in binding $value

I need help testing for Nil

2020-05-26 Thread ToddAndMargo via perl6-users
Hi All, How do I turn this: $ raku -e 'my $x="abc"; say $x.index( "q" );' Nil into a test? $ raku -e 'my $x="abc"; if $x.index( "q" ) eq Nil {say "Nil"}else{say "Exists";}' Use of Nil in string context in bloc

Re: Need help with Nil values

2016-02-22 Thread Timo Paulssen
Hello Emiliano, In this case, I think you may want to use just "Str" instead of "Nil". "Str" is the "type object" for Str objects, and you can check whether it's a string like "foo" or just the Str object by checking $!value.defined. Th

Re: Need help with Nil values

2016-02-22 Thread Brandon Allbery
On Mon, Feb 22, 2016 at 9:15 PM, TS xx wrote: > I expect $.value to hold Strings, but I want to be able to instantiate > MyClass whether I have a value already or not, and I also want to be able > to tell if $.value has a real String or not. Is this possible? You don't want Nil t

Re: Need help with Nil values

2016-02-22 Thread TS xx
Thanks, That was it. Somtimes I get confused with the way other languages treat undefined/null/nil values. Regards, Emiliano From: Timo Paulssen Sent: Tuesday, February 23, 2016 2:20 AM To: perl6-users@perl.org Subject: Re: Need help with Nil values

Re: Need help with Nil values

2016-02-22 Thread TS xx
Thanks Brandon, That was what I was looking for. I'm trying it already. Regards, Emiliano From: Brandon Allbery Sent: Tuesday, February 23, 2016 2:21 AM To: TS xx Cc: perl6-users@perl.org Subject: Re: Need help with Nil values On Mon, Feb 22, 2016

Re: Need help with Nil values

2016-02-23 Thread Lloyd Fournier
> > Regards, > > Emiliano > > > -- > *From:* Brandon Allbery > *Sent:* Tuesday, February 23, 2016 2:21 AM > *To:* TS xx > *Cc:* perl6-users@perl.org > > *Subject:* Re: Need help with Nil values > On Mon, Feb 22, 2016 at 9:15 PM, TS xx wrote: > &g

Re: I need help testing for Nil

2020-05-26 Thread Brad Gilbert
Generally you don't need to test for 「Nil」. You can just test for defined-ness. $ raku -e 'my $x="abc"; with $x.index( "q" ) {say "Exists"} else {say "Nil";}' Also 「Nil」 is not a 「Str」, so why would you use 「eq」? $ raku -e 'N

Re: I need help testing for Nil

2020-05-26 Thread ToddAndMargo via perl6-users
On Tue, May 26, 2020 at 4:24 PM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Hi All, How do I turn this: $ raku -e 'my $x="abc"; say $x.index( "q" );' Nil into a test? $ raku -e 'my $x="abc&q

Re: I need help testing for Nil

2020-05-26 Thread Brad Gilbert
via perl6-users > >> mailto:perl6-users@perl.org>> wrote: > >> > >> Hi All, > >> > >> How do I turn this: > >> > >> $ raku -e 'my $x="abc"; say $x.index( "q" );' > >> Nil > &

Re: I need help testing for Nil

2020-05-26 Thread ToddAndMargo via perl6-users
On 2020-05-26 16:29, Brad Gilbert wrote: There are various equality operators. 「==」 Tests for numeric equality 「eq」 Tests for string equality 「===」 Tests for value identity 「=:=」 Tests for pointer equality (Note that it looks a bit like 「:=」) 「eqv」 Tests for structure equivalence. The 「==」 and

Different return values with "say" vs "put" (Nil representation... )

2020-05-18 Thread William Michels via perl6-users
correctly returned; in bash line [3] using "say" only the $/ match string is returned. So far so good. However, a virtually-identical call in bash line [4] using "put" instead of "say" returns an error for the first line of the target text file: "Use of Nil in st

Re: Different return values with "say" vs "put" (Nil representation... )

2020-05-18 Thread Patrick R. Michaud
"say $x" is essentially equivalent to "put $x.gist". Since Nil is undefined (roughly equivalent to a type object), Nil.gist has a string value of "Nil" and can be printed. However, attempting to convert Nil directly into a Str throws an error because tha

Re: Different return values with "say" vs "put" (Nil representation... )

2020-05-18 Thread Brad Gilbert
> Bool.Str Use of uninitialized value of type Bool in string context. Methods .^name, .raku, .gist, or .say can be used to stringify it to something meaningful. in block at line 1 > Nil.Str Use of Nil in string context in block at line 1 Which means

Re: Different return values with "say" vs "put" (Nil representation... )

2020-05-18 Thread William Michels via perl6-users
On Mon, May 18, 2020 at 4:03 AM Patrick R. Michaud wrote: > > "say $x" is essentially equivalent to "put $x.gist". > > Since Nil is undefined (roughly equivalent to a type object), Nil.gist has a > string value of "Nil" and can be printed. However,

Re: Different return values with "say" vs "put" (Nil representation... )

2020-05-18 Thread William Michels via perl6-users
gt; Many objects will throw an error if you call `.Str` on them when they are > undefined. > > > Bool.Str > Use of uninitialized value of type Bool in string context. > Methods .^name, .raku, .gist, or .say can be used to stringify it to > something meaningful. >

zef install Linenoise: Use of Nil in string context, (Linenoise) line 15

2018-04-24 Thread mimosinnet
This message appears when installing Linenoise <--- $ zef install Linenoise ===> Installing: Linenoise:ver<0.1.1>:auth Use of Nil in string context in block at home#sources/0BDF8C54D33921FEA066491D8D13C96A7CB144B9 (Linenoise) line 15 ---> The above mentioned line is: <

Re: zef install Linenoise: Use of Nil in string context, (Linenoise) line 15

2018-04-25 Thread Todd Chester
On 04/24/2018 11:30 AM, mimosinnet wrote: This message appears when installing Linenoise <--- $ zef install Linenoise ===> Installing: Linenoise:ver<0.1.1>:auth Use of Nil in string context  in block  at home#sources/0BDF8C54D33921FEA066491D8D13C96A7CB144B9 (Linenoise) line 1

Re: zef install Linenoise: Use of Nil in string context, (Linenoise) line 15

2018-04-26 Thread mimosinnet
El Wednesday, 25 de April del 2018 a les 18:31, Todd Chester va escriure: On 04/24/2018 11:30 AM, mimosinnet wrote: This message appears when installing Linenoise <--- $ zef install Linenoise ===> Installing: Linenoise:ver<0.1.1>:auth Use of Nil in string context  in block  at

Re: zef install Linenoise: Use of Nil in string context, (Linenoise) line 15

2018-04-26 Thread ToddAndMargo
On 04/26/2018 12:45 AM, mimosinnet wrote: El Wednesday, 25 de April del 2018 a les 18:31, Todd Chester va escriure: On 04/24/2018 11:30 AM, mimosinnet wrote: This message appears when installing Linenoise <--- $ zef install Linenoise ===> Installing: Linenoise:ver<0.1.1>:auth U