News:

Who uses forums anymore?

Main Menu

Perl oddities

Started by deadly7, August 26, 2011, 06:28:32 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

deadly7

Today at work I discovered Perl has an "OR" operator and the usual "||" operator. They have different precedence. In fact, "OR" is the lowest of operators.

lolwtf
[17:42:21.609] <Ergot> Kutsuju you're girlfrieds pussy must be a 403 error for you
[17:42:25.585] <Ergot> FORBIDDEN

on IRC playing T&T++
<iago> He is unarmed
<Hitmen> he has no arms?!

on AIM with a drunk mythix:
(00:50:05) Mythix: Deadly
(00:50:11) Mythix: I'm going to fuck that red dot out of your head.
(00:50:15) Mythix: with my nine

Sidoh


MyndFyre

Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.

You think that's odd?  How about JavaScript - did you know that JavaScript invented the !! operator?  (Not part of the language spec but it has its uses).  It also has the === and !== to prevent type coercion when determining equality....
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

deadly7

Quote from: MyndFyre on August 28, 2011, 04:52:07 PM
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.
This makes more sense than "||" and "OR"
[17:42:21.609] <Ergot> Kutsuju you're girlfrieds pussy must be a 403 error for you
[17:42:25.585] <Ergot> FORBIDDEN

on IRC playing T&T++
<iago> He is unarmed
<Hitmen> he has no arms?!

on AIM with a drunk mythix:
(00:50:05) Mythix: Deadly
(00:50:11) Mythix: I'm going to fuck that red dot out of your head.
(00:50:15) Mythix: with my nine

iago

Quote from: MyndFyre on August 28, 2011, 04:52:07 PM
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.

You think that's odd?  How about JavaScript - did you know that JavaScript invented the !! operator?  (Not part of the language spec but it has its uses).  It also has the === and !== to prevent type coercion when determining equality....
php also has === and !==. They're actually really useful. :)

I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)

Blaze

Quote from: iago on August 28, 2011, 06:20:05 PM
Quote from: MyndFyre on August 28, 2011, 04:52:07 PM
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.

You think that's odd?  How about JavaScript - did you know that JavaScript invented the !! operator?  (Not part of the language spec but it has its uses).  It also has the === and !== to prevent type coercion when determining equality....
php also has === and !==. They're actually really useful. :)

I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)


Vouching !== and === usefulness; if a function returns 0 as a valid, that's not false!  They're also fractionaly faster than their typeless alternative comparisons.
And like a fool I believed myself, and thought I was somebody else...

rabbit

Quote from: Blaze on August 28, 2011, 06:35:27 PM
Quote from: iago on August 28, 2011, 06:20:05 PM
Quote from: MyndFyre on August 28, 2011, 04:52:07 PM
Apparently it also has eq, ne, lt, gt, le, ge, and.  Evidently, symbolic operators (==, !=, <, >, <=, >=, &&, and ||) are used for numbers, whereas their textual counterparts are for strings.

You think that's odd?  How about JavaScript - did you know that JavaScript invented the !! operator?  (Not part of the language spec but it has its uses).  It also has the === and !== to prevent type coercion when determining equality....
php also has === and !==. They're actually really useful. :)

I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)


Vouching !== and === usefulness; if a function returns 0 as a valid, that's not false!  They're also fractionaly faster than their typeless alternative comparisons.
I love !== and ===

Sidoh

Yeah, you almost need something like === in a weakly-typed language.

rabbit

Quote from: Sidoh on August 28, 2011, 09:00:32 PM
Yeah, you almost need something like === in a weakly-typed language.
I prefer to "variably lenient language"

Sidoh

Quote from: rabbit on August 28, 2011, 09:02:35 PM
Quote from: Sidoh on August 28, 2011, 09:00:32 PM
Yeah, you almost need something like === in a weakly-typed language.
I prefer to "variably lenient language"

I've decided that I probably love ruby, but I think I still really dislike "variably lenient languages".

Blaze

Quote from: Sidoh on August 28, 2011, 09:05:05 PM
Quote from: rabbit on August 28, 2011, 09:02:35 PM
Quote from: Sidoh on August 28, 2011, 09:00:32 PM
Yeah, you almost need something like === in a weakly-typed language.
I prefer to "variably lenient language"

I've decided that I probably love ruby, but I think I still really dislike "variably lenient languages".

Make a class for each variable type that forces a explicit type.  :smugface:
And like a fool I believed myself, and thought I was somebody else...

Sidoh

Quote from: Blaze on August 28, 2011, 09:14:35 PM
Quote from: Sidoh on August 28, 2011, 09:05:05 PM
Quote from: rabbit on August 28, 2011, 09:02:35 PM
Quote from: Sidoh on August 28, 2011, 09:00:32 PM
Yeah, you almost need something like === in a weakly-typed language.
I prefer to "variably lenient language"

I've decided that I probably love ruby, but I think I still really dislike "variably lenient languages".

Make a class for each variable type that forces a explicit type.  :smugface:

Heh, but that doesn't prevent compile errors when you pass one type into a method expecting another type. Just so many problems. You can avoid them pretty well with a dose of convention and care, but it's just so much easier in a language like Java.

Don't get me wrong -- there are things that I'd never choose to do in Java. There are just a couple of things that creep me out about Ruby.

MyndFyre

Quote from: iago on August 28, 2011, 06:20:05 PM
php also has === and !==. They're actually really useful. :)
I agree.  We actually just standardized using these operators on my team at work unless there's a really good reason not to.

Quote from: iago on August 28, 2011, 06:20:05 PM
I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)
Yeah, it coerces the value into a true Boolean (something about the phrase "true Boolean" is making me laugh).  Also fun is its counterpart, !!!.  :)  (There's actually no reason for !!!, since a single ! will coerce the value into the true Boolean value opposite of the meaning of the original).
Quote from: Joe on January 23, 2011, 11:47:54 PM
I have a programming folder, and I have nothing of value there

Running with Code has a new home!

Quote from: Rule on May 26, 2009, 02:02:12 PMOur species really annoys me.

iago

Quote from: MyndFyre on August 29, 2011, 01:24:54 AM
Quote from: iago on August 28, 2011, 06:20:05 PM
I've never seen !!, but I'm guessing it converts a value to either 'true' or 'false' by negating it twice? If so, assembly's been doing that forever. :)
Yeah, it coerces the value into a true Boolean (something about the phrase "true Boolean" is making me laugh).  Also fun is its counterpart, !!!.  :)  (There's actually no reason for !!!, since a single ! will coerce the value into the true Boolean value opposite of the meaning of the original).
!! and !!! and !!!! and etc seem more like conventions than actual operators, since they're just abusing the functionality that ! provides. :)

I hadn't really thought of using those before, though, it's kinda neat. And I imagine fairly language agnostic, unless some stupid language uses ! for a bitwise negate instead of logical. But they're stupid. :)