Re: definitions of truth

2004-06-28 Thread Dan Hursh
Paul Hodges wrote: --- Jonadab the Unsightly One [EMAIL PROTECTED] wrote: Consider this test in Perl: if \0 {...} Its equivalent in C is this: if () ... That can't be right. If anything it's got the two languages flipped, but that's still not quite right either. Apples and orange

Re: definitions of truth

2004-06-26 Thread Simon Cozens
[EMAIL PROTECTED] (Paul Hodges) writes: Do note that I realize I can check it. It's just that for no reason I can quite define, my C background wants a null byte to be FALSE without any special chicanery on my part when checking. I can live with the fact it isn't going to be, it just seems odd

Re: definitions of truth

2004-06-26 Thread Jonadab the Unsightly One
Paul Hodges wrote: Do note that I realize I can check it. It's just that for no reason I can quite define, my C background wants a null byte to be FALSE without any special chicanery on my part when checking. I can live with the fact it isn't going to be, it just seems odd to me. If that seems odd

Re: definitions of truth

2004-06-26 Thread Brent 'Dax' Royal-Gordon
Paul Hodges wrote: --- Spider Boardman [EMAIL PROTECTED] wrote: You need ord() for character/grapheme/byte/whatever testing that's equivalent to what C does. Since C doesn't really have strings, and Perl does, this is just one of those differences between the languages where (essentially, and

Re: definitions of truth

2004-06-26 Thread Paul Hodges
--- Simon Cozens [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] (Paul Hodges) writes: Do note that I realize I can check it. It's just that for no reason I can quite define, my C background wants a null byte to be FALSE without any special chicanery on my part when checking. I can live with

Re: definitions of truth

2004-06-26 Thread Paul Hodges
--- Jonadab the Unsightly One [EMAIL PROTECTED] wrote: Paul Hodges wrote: Do note that I realize I can check it. It's just that for no reason I can quite define, my C background wants a null byte to be FALSE without any special chicanery on my part when checking. I can live with the

Re: definitions of truth

2004-06-26 Thread Paul Hodges
--- Brent 'Dax' Royal-Gordon [EMAIL PROTECTED] wrote: Paul Hodges wrote: --- Spider Boardman [EMAIL PROTECTED] wrote: You need ord() for character/grapheme/byte/whatever testing that's equivalent to what C does. Since C doesn't really have strings, and Perl does, this is just one of those

Re: definitions of truth

2004-06-25 Thread David Storrs
On Thu, Jun 24, 2004 at 12:43:30PM -0700, Scott Bronson wrote: So, in summary, though 0==false appears to work, it leads to a number of strange boundary conditions and, therefore, bugs. It's hard for new programmers to grasp and even old hacks are still sometimes tripped up by it. It just

Re: definitions of truth

2004-06-25 Thread Matthew Walton
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Paul Hodges wrote: | --- Luke Palmer [EMAIL PROTECTED] wrote: | |Paul Hodges writes: | |So, in P6: | | if 0 { print 0\n; } # I assume this won't print. | if '0' { print '0'\n; } # I assume this won't print. | if ''{ print ''\n;}

Re: definitions of truth

2004-06-25 Thread Jonadab the Unsightly One
Paul Hodges wrote: So a null byte is still Boolean true. Ugh, yarf, ack, etc. But as long as I know -- easy enough to check explicitly. But just tell me thisam I the only guy who thinks this *feels* wierd? It doesn't feel weird to me, but my previous languages of choice were fairly high-level

Re: definitions of truth

2004-06-25 Thread Brent 'Dax' Royal-Gordon
Paul Hodges wrote: So a null byte is still Boolean true. But just tell me thisam I the only guy who thinks this *feels* wierd? Understanding the reason doesn't make it any more ~comfortable~. I think you are. Perl considers null to be data--it's that simple. Remember, while Perl can work

Re: definitions of truth

2004-06-25 Thread Spider Boardman
At some point in history, Paul Hodges wrote (in part): ph So a null byte is still Boolean true. Ugh, yarf, ack, etc. No. And it never has been (at least in my world view). However, asking that question explains some things. See below for more. ph But as long as I know -- easy enough to

Re: definitions of truth

2004-06-25 Thread Scott Bronson
On Thu, 2004-06-24 at 21:45, Brent 'Dax' Royal-Gordon wrote: Perhaps not as happy as you think: my $foo = '0'; my String $bar = '0'; if $foo { say 'foo true' } if $bar { say 'bar true' } Would print 'bar true', but not 'foo true'. Frankly, I love it. Since I plan on

Re: definitions of truth

2004-06-25 Thread Paul Hodges
--- Spider Boardman [EMAIL PROTECTED] wrote: At some point in history, Paul Hodges wrote (in part): ph So a null byte is still Boolean true. Ugh, yarf, ack, etc. No. And it never has been (at least in my world view). A valid point, though I reply: my $x = \0; print true if $x;

definitions of truth

2004-06-24 Thread Hodges, Paul
Every now and then I have this discussion with people at work that involve Perl's ideas of boolean truth. I usually break it down like this: In Perl5, the following values are FALSE: undef, '0', 0, and ''. Anything not in that list is considered TRUE in a boolean context. That means that

Re: definitions of truth

2004-06-24 Thread Jonadab the Unsightly One
In Perl5, the following values are FALSE: undef, '0', 0, and ''. What you fail to note is that each of these is false for a reason. undef is false so that you can test an object for truth; if it is undef it obviously contains no data, so it's false. 0 is false so that you can test numbers for

Re: definitions of truth

2004-06-24 Thread Scott Bronson
On Thu, 2004-06-24 at 08:04, Jonadab the Unsightly One wrote: In Perl5, the following values are FALSE: undef, '0', 0, and ''. ... The really special case is '0', which is false for arcane (but very sensible) reasons. I don't agree that '0' being false is sensible. This, plus less than

Re: definitions of truth

2004-06-24 Thread Scott Bronson
On Thu, 2004-06-24 at 10:44, Scott Bronson wrote: I don't agree that '0' being false is sensible... I don't mean to imply that I think it's senseless. Just that, to me, it smells suspiciously like a hack. :) - Scott

Re: definitions of truth

2004-06-24 Thread Juerd
Scott Bronson skribis 2004-06-24 10:44 (-0700): However, it seems that because Perl is finally getting a typing system, this hack can be fixed in Perl itself! No programmer intervention needed. Undef and '' can be false for strings, undef and 0 can be false for integers, undef, 0, and 0.0

Re: definitions of truth

2004-06-24 Thread Larry Wall
On Thu, Jun 24, 2004 at 08:04:10PM +0200, Juerd wrote: : Scott Bronson skribis 2004-06-24 10:44 (-0700): : However, it seems that because Perl is finally getting a typing system, : this hack can be fixed in Perl itself! No programmer intervention : needed. Undef and '' can be false for

Re: definitions of truth

2004-06-24 Thread Smylers
Scott Bronson writes: On Thu, 2004-06-24 at 08:04, Jonadab the Unsightly One wrote: In Perl5, the following values are FALSE: undef, '0', 0, and ''. ... The really special case is '0', which is false for arcane (but very sensible) reasons. I don't agree that '0' being false is

Re: definitions of truth

2004-06-24 Thread Juerd
Larry Wall skribis 2004-06-24 11:29 (-0700): This is Perl 6. Everything is an object, or at least pretends to be one. Everything has a .boolean method that returns 0 or 1. All conditionals call the .boolean method, at least in the abstract. (The optimizer is free to optimize the method call

Re: definitions of truth

2004-06-24 Thread Larry Wall
On Thu, Jun 24, 2004 at 08:44:45PM +0200, Juerd wrote: : Larry Wall skribis 2004-06-24 11:29 (-0700): : This is Perl 6. Everything is an object, or at least pretends to be one. : Everything has a .boolean method that returns 0 or 1. All conditionals : call the .boolean method, at least in the

Re: definitions of truth

2004-06-24 Thread Scott Bronson
On Thu, 2004-06-24 at 11:34, Smylers wrote: Scott Bronson writes: But you're fine with 0 being false? 0 and '0' are pretty much interchangeable in Perl 5 -- wherever you can use one, you can use the other and it gets coerced to it. Let's back up... Strings and numbers are meant to be

Re: definitions of truth

2004-06-24 Thread Juerd
Larry Wall skribis 2004-06-24 12:24 (-0700): Well, the type/property name doesn't have to be boolean--it could be truth, instead. I understand that 'true' and 'false' can't be used. However, truth is in the same category as definedness, and $foo.definedness looks awful :) Perhaps for

Re: definitions of truth

2004-06-24 Thread Jonadab the Unsightly One
Larry Wall wrote: What do you mean by length? For a string, it obviously either means number of bytes or number of characters. Pick one, document it, and let people who want the other semantic use a pragma. I don't think it matters which one you pick as default, as long as it's clearly

Re: definitions of truth

2004-06-24 Thread Larry Wall
On Thu, Jun 24, 2004 at 04:19:25PM -0400, Jonadab the Unsightly One wrote: : Larry Wall wrote: : : What do you mean by length? : : For a string, it obviously either means number of bytes or number : of characters. Pick one, document it, and let people who want the : other semantic use a

Re: definitions of truth

2004-06-24 Thread Smylers
Scott Bronson writes: On Thu, 2004-06-24 at 11:34, Smylers wrote: But you're fine with 0 being false? 0 and '0' are pretty much interchangeable in Perl 5 -- wherever you can use one, you can use the other and it gets coerced to it. Let's back up... Strings and numbers are meant to

Re: definitions of truth

2004-06-24 Thread Dave Whipp
Larry Wall [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This is Perl 6. Everything is an object, or at least pretends to be one. Everything has a .boolean method that returns 0 or 1. All conditionals call the .boolean method, at least in the abstract. My reading of A12 leads me

Re: definitions of truth

2004-06-24 Thread Austin Hastings
--- Dave Whipp [EMAIL PROTECTED] wrote: Larry Wall [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This is Perl 6. Everything is an object, or at least pretends to be one. Everything has a .boolean method that returns 0 or 1. All conditionals call the .boolean method, at

Re: definitions of truth

2004-06-24 Thread Juerd
Austin Hastings skribis 2004-06-24 14:29 (-0700): $foo as boolean This is Perl 6. Everything is an object, or at least pretends to be one. Everything has a .boolean method that returns 0 or 1. If I understand the current design correctly, having both .boolean and casting via as would mean

Re: definitions of truth

2004-06-24 Thread Austin Hastings
--- Juerd [EMAIL PROTECTED] wrote: Austin Hastings skribis 2004-06-24 14:29 (-0700): $foo as boolean This is Perl 6. Everything is an object, or at least pretends to be one. Everything has a .boolean method that returns 0 or 1. If I understand the current design correctly, having

Re: definitions of truth

2004-06-24 Thread Juerd
Austin Hastings skribis 2004-06-24 15:54 (-0700): I'd say yeah, it is. 0-but-true is pretty nice to have. (Finally the system calls can return something other than -1.) That we already have. 0 but true. (perldoc -f fcntl) It's 1 but false that's really special :) Juerd

Re: definitions of truth

2004-06-24 Thread Larry Wall
On Thu, Jun 24, 2004 at 03:24:25PM -0700, Scott Walters wrote: : I want an okay. Routines should be able to return okay to indicate : an ambivalent degree of success. okay would be defined as true | false, Some messages want to be simultaneously Warnocked and not Warnocked... Larry

RE: definitions of truth

2004-06-24 Thread Joe Gottman
-Original Message- From: Dave Whipp [mailto:[EMAIL PROTECTED] Sent: Thursday, June 24, 2004 5:22 PM To: [EMAIL PROTECTED] Subject: Re: definitions of truth Larry Wall [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] This is Perl 6. Everything is an object

Re: definitions of truth

2004-06-24 Thread Scott Bronson
On Thu, 2004-06-24 at 14:17, Smylers wrote: Because the above would've been insane: saying that Csif ($x) treats $x as a string would be pretending that Cif always treats its arguments as numbers, but something such as Cif ($x eq 'frog') doesn't have any numbers in it. Doesn't it? perl -e

Re: definitions of truth

2004-06-24 Thread Paul Hodges
I seemed to have opened a can of worms, lol But did anybody see the one that had something to do with my question crawling around? (I've obviously missed a couple of messages. They're probably hanging out down at the router in the cyberspace equivelent of teenagers ogling girls on the street

Re: definitions of truth

2004-06-24 Thread Luke Palmer
Paul Hodges writes: I seemed to have opened a can of worms, lol But did anybody see the one that had something to do with my question crawling around? (I've obviously missed a couple of messages. They're probably hanging out down at the router in the cyberspace equivelent of teenagers

Re: definitions of truth

2004-06-24 Thread Jonadab the Unsightly One
Juerd wrote: That we already have. 0 but true. (perldoc -f fcntl) It's 1 but false that's really special :) No, what's really special is the ability to return entirely different things in string versus numeric context, like the magic $! does in Perl5. That, or interesting values of undef :-)

Re: definitions of truth

2004-06-24 Thread Paul Hodges
--- Luke Palmer [EMAIL PROTECTED] wrote: Paul Hodges writes: So, in P6: if 0 { print 0\n; } # I assume this won't print. if '0' { print '0'\n; } # I assume this won't print. if ''{ print ''\n;} # I assume this won't print. if undef { print undef\n; } # I

Re: definitions of truth

2004-06-24 Thread Brent 'Dax' Royal-Gordon
Scott Bronson wrote: That's the plan? Happy day! I was not aware of that. Because I didn't see anything about this in Perl 6 Essentials, I just figured that Perl5's '0'==undef was being brought forward into Perl6. The horror! Sorry for the bad assumption. :) Perhaps not as happy as you