say's return value

2005-07-30 Thread Gaal Yahas
What do print and say return?

fail would be great on errors. On success, they return 1 now, which
doesn't look very useful. How about returning the printed string? Unless
called in void context, of course.

(This introduces a potential semipredicate problem when looking at the
return value of a printed 0 or  while not using fatal, but the
code can use a defined guard.)

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/


Re: say's return value

2005-07-30 Thread chromatic
On Sat, 2005-07-30 at 14:56 +0300, Gaal Yahas wrote:

 (This introduces a potential semipredicate problem when looking at the
 return value of a printed 0 or  while not using fatal, but the
 code can use a defined guard.)

I don't know if returning the printed string is the right approach, but
would returning '$string but true' avoid the semipredicate problem?

-- c



Re: say's return value

2005-07-30 Thread Larry Wall
On Sat, Jul 30, 2005 at 09:25:12AM -0700, chromatic wrote:
: On Sat, 2005-07-30 at 14:56 +0300, Gaal Yahas wrote:
: 
:  (This introduces a potential semipredicate problem when looking at the
:  return value of a printed 0 or  while not using fatal, but the
:  code can use a defined guard.)
: 
: I don't know if returning the printed string is the right approach, but
: would returning '$string but true' avoid the semipredicate problem?

I don't see any reason to return the string at all.  It's almost never
wanted, and you can always use .= or monkey but.

Larry


Re: say's return value

2005-07-30 Thread Gaal Yahas
On Sat, Jul 30, 2005 at 09:36:13AM -0700, Larry Wall wrote:
 I don't see any reason to return the string at all.  It's almost never
 wanted, and you can always use .= or monkey but.

So: fail on failure bool::true on success? Pugs currently returns
bool::true.

Is there a way to tag a sub as failable? Should there be one?

-- 
Gaal Yahas [EMAIL PROTECTED]
http://gaal.livejournal.com/