--G4iJoqBmSsgzjUCe Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Aug 31, 2006 at 03:01:26AM +0900, Rick DeNatale wrote: > On 8/30/06, Jgen Strobel <strobel / secure.at> wrote: > >On Tue, Aug 29, 2006 at 08:55:09AM +0900, Michael W. Ryder wrote: > >I wouldn't say it is wrong the way ruby does it, but not exactly > >intuitive either. Choosing to follow english language rather than > >widespread convention *and* similiar constructs in ruby itself (&&, > >||, +, *, ...) may seem a bit ... anti POLS. > > A perl programmer would be very surprised if AND, OR, && and || worked > any other way. Probably the most common perl idiom here is: > > "some long complicated expression" or die That's not a complete example, as no precedence rules come into play here. and and or are pretty low-precedence operators in perl and ruby alike, which makes constructs like the above possible without parenthesises. But what I am driving at is this: irb(main):035:0> 1 + 2 * 6 => 13 irb(main):036:0> 1 | 2 & 6 => 3 irb(main):037:0> 1 | (2 & 6) => 3 irb(main):038:0> (1 | 2) & 6 => 2 Clearly, & binds stronger than |, same as * binds stronger than +. (In a boolean algebra those operations are the same respectively). irb(main):073:0> def pr(x) p x; x; end => nil irb(main):076:0> (pr 1) || (pr 2) && (pr 3) 1 => 1 irb(main):077:0> (pr 1) or (pr 2) and (pr 3) 1 3 => 3 In the first case, && binds stronger than ||, but is short circuited away. In the second case "and" does not bind stronger than "or", which suprised me, given prior knowledge. Is it really only me? -Jgen -- The box said it requires Windows 95 or better so I installed Linux --G4iJoqBmSsgzjUCe Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iQEVAwUBRPfO0Py64gyiEfXtAQKqzQgAgmuSapjIucsQxfnX7Qrq1uwPKrGZU+az u0CKHkqhsPntCNUIGizawZaqC4g8VCavc1zVqwIcdGJmB0uBx42hg+auxGIE9itP ZarfcskzrJPTEZRuwGrM7XOejVItN4+PGrWa0aA7ExFjaR8R1+DE06eHAjfkehDE kpswRNz4wpAiAcVonPPTApkApmXmePOXcSAkyWFqSceI9KG0C/WB8xwK85DPLv4C KHf5idD+m0Ne5G4xdZ9h7u8SitB3qskUCHDz7uLIIx0RtMDodpZ5F5FZxU9R3gbE QDwU1a8W3+hPNGInG830CSGNk4oqGNn12NolR8YFVSau+HmZ34SRzg ¥ßtm -----END PGP SIGNATURE----- --G4iJoqBmSsgzjUCe--