moderated >> 'but' as a synonym for 'and?

by mpersico » Thu, 31 Aug 2006 09:31:27 GMT

I don't know how exactly to propose this, but here it goes.

Take a look at this contrived example (yes I could factor it - please
ignore that for now):

if(sky() eq 'grey' and raining()) {
print "bring an umbrella\n";
}
if(sky() eq 'grey' and not raining()) {
print "no need for an umbrella\n";
}

Wouldn't it read better this way:

if(sky() eq 'grey' and raining()) {
print "bring an umbrella\n";
}
if(sky() eq 'grey' BUT not raining()) {
print "no need for an umbrella\n";
}

I'd like to see 'but' as a synonym for 'and'. You would use it when the
second condition has to evaluate to logical true, but (no pun
intended), the truth is not the expected condition.

Comments?

moderated >> 'but' as a synonym for 'and?

by Christian Winter » Fri, 08 Sep 2006 04:52:07 GMT



I'm not quite sure we need another keyword just for that, but it
could be implemented quickly using Filter::Simple:
-----------------------------------------------------------------
package ANDBUT;

use Filter::Simple;

FILTER_ONLY
code => sub { s/\bbut\b/and/g };

1;
-----------------------------------------------------------------
That should be all, and after saving that one into ANDBUT.pm and
saying e.g.:

use ANDBUT;

if( $dog->is("huge") but not $dog->waggles("tail") )
{
run_away("fast") or die("cruelly");
}

everything should run (no pun intended ;). Of course one has to keep
in mind that the whole source has to be processed by the regex, so I'd
not use it with big scripts.

-Chris

Similar Threads

1. DBD::Oracle 1.22 - Problem inserting BLOB via synonym

Hi,

The problem that existed for CLOB's and BLOB's in 1.21 has been
partially fixed.  The good news is that CLOB's appear to be OK.

BLOB's however appear to still be broken.  Here is an extract from a
level 3 trace ...

    DBI::db=HASH(0x61b8350) trace level set to 0x0/3 (DBI @
0x0/47120086204416) in DBI 1.52-ithread (pid 27618)
    -> prepare for DBD::Oracle::db (DBI::db=HASH(0x61a64d0)~0x61b8350 '
            INSERT
            INTO    sb_demo(data_b)
            VALUES  (:blob)
        ') thr#4e9b010
    dbih_setup_handle(DBI::st=HASH(0x632baa0)=>DBI::st=HASH(0x632bb90),
DBD::Oracle::st, 632bba0, Null!)
    dbih_make_com(DBI::db=HASH(0x61b8350), 61c0570, DBD::Oracle::st,
448, 0) thr#4e9b010
    dbd_preparse scanned 1 distinct placeholders
    dbd_st_prepare'd sql INSERT (pl1, auto_lob1, check_sql1)
    dbd_describe skipped for INSERT
    <- prepare= DBI::st=HASH(0x632baa0) at tst-utf8.plx line 191 via  at
tst-utf8.plx line 239
    -> bind_param for DBD::Oracle::st (DBI::st=HASH(0x632baa0)~0x632bb90
':blob' '..............' (type 0 (DEFAULT (varchar)), attribs:
HASH(0x6311c40))
      bind :blob as ftype 113 (SQLT_BLOB / long)
dbd_rebind_ph(): bind :blob <== '........' (in, not-utf8, csid 0->0->0,
ftype 113 (SQLT_BLOB / long), csform 0->0, maxlen 8, maxdata_size 0)
    <- bind_param= 1 at tst-utf8.plx line 197 via  at tst-utf8.plx line
239
    -> execute for DBD::Oracle::st (DBI::st=HASH(0x632baa0)~0x632bb90)
thr#4e9b010
   dbd_st_execute INSERT (out0, lob1)...
Statement Execute Mode is 0 (DEFAULT)
    dbd_st_execute INSERT returned (SUCCESS, rpc1, fn3, out0)
       lob refetching a synonym named=SB_DEMO for FRAMEWORK.SB_DEMO 
       lob refetch from table FRAMEWORK.SB_DEMO, 3 columns:
       lob refetch table col 1: 'LINE_NUMBER' otype 2
       lob refetch table col 2: 'TEXT' otype 1
       lob refetch table col 3: 'DATA_B' otype 113
       lob refetch :blob param: otype 113, matched field 'DATA_B' by
type (DATA_B "blob")
       lob refetch sql: select DATA_B "blob" from DATA_B "blob" where
rowid = :rid for update
       lob refetch 1 for ':blob' param: ftype 113 setup
    !! ERROR: '942' 'ORA-00942: table or view does not exist (DBD ERROR:
OCIStmtExecute/LOB refetch)' (err#1)
    <- execute= undef at tst-utf8.plx line 198 via  at tst-utf8.plx line
239
    -> HandleError on DBI::st=HASH(0x632bb90) via CODE(0x6311080)
(undef)

It appears it is attempting to use the BLOB column name for the table
name in the refetch SQL statement.

Thanks for your help.

Steve



******************************************************************
This email is intended solely for the use of the addressee and may
contain information that is confidential, proprietary, or both.
If you receive this email in error please immediately notify the
sender and delete the email.
******************************************************************

2. DBD::Oracle: Synonym translation no longer valid? - Perl DBI

3. LOB retech fails through synonym

The LOB magic that goes on during an insert breaks when the insert is
through a synonym into a global temp table containing a CLOB.

The refetch of the locator fails in perl, although via sql*plus it
works fine through the synonym.  prefixing the table with the schema
name fixes the problem.

I doubt it has anything to do with the global temp table, just happens
to be where my clob is going.