Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
30 TO 50 FERAL HOG
Mar 2, 2005



because it doesn't make sense?

like apple + potato doesn't equal apple

anything / 0 is NaN

infinity + 1 is still infinity

an int + a thing that is not an int isn't an int

although perhaps you are a php developer

Adbot
ADBOT LOVES YOU

akadajet
Sep 14, 2003

akadajet
Sep 14, 2003

HoboMan
Nov 4, 2010


hahaha what the gently caress?

VikingofRock
Aug 24, 2008




Hey at least it's commutative!

HoboMan
Nov 4, 2010

literally
true == NaN

i can't deal with this
goondolences to every php dev

e:
0 == "php"
gently caress i cant stop laughing

HoboMan fucked around with this message at 04:55 on Mar 24, 2016

raminasi
Jan 25, 2005

a last drink with no ice

Condiv posted:

:confused: how does 0 + null = null make any sense at all?

null + null rightfully doesn't compile, so 0 cannot be being cast to null

fake edit: i just tried 0 + null in ideone and it comes back as 0, which is the sane result (though lovely cause it's implicitly casting null to int)

MSDN posted:

The predefined unary and binary operators and any user-defined operators that exist for value types may also be used by nullable types. These operators produce a null value if the operands are null; otherwise, the operator uses the contained value to calculate the result.

vs immediate:

code:
(int?)0 + (int?)null
null
(int?)0 + default(int?)
null

Jerry Bindle
May 16, 2003
false == 0 == "php" == true

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
the past tense verb for getting a kik message is "kiked"

just an fyi

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
poo poo was going well until i got kiked

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
i kept my node modules open sourced until those lawyers kiked me

FamDav
Mar 29, 2008
this is all solved in a very reasonable way in haskell with monoids btw.

KidDynamite
Feb 11, 2005

where can i learn more about schema-less databases? boss wants me to have real reason for wanting a normalized relational db even though we we need to emulate relationships in a schema-less db. i think he's pushing me to my limits and trying to make me learn some poo poo rather that just letting me get away with saying schema-less is bad so i can grow as a dev. i really appreciate it and don't want to let him down. also i would like to get to coding so the quicker all this poo poo is taken care off the better.

jony neuemonic
Nov 13, 2009

HoboMan posted:

goondolences to every php dev

thank you.

:smith:

raminasi
Jan 25, 2005

a last drink with no ice
i have a terrible programmer question about testing (in c#). i am writing a plugin for other software. every api i interact with uses concrete objects. how do i fake objects for testing? for example, say i've got
a FiddleWithHostDocument(HostDocument doc) method, and i want to make sure that when it runs, it sets the HostDocument.IsModified flag on the document it's passed. i can't just mock out HostDocument, because it's sealed. the only thing i was able to think of (other than using one of those mocking frameworks that rewrites IL or whatever) was, for each host api class i care about, to create a corresponding wrapper interface and concrete implementation that forwards interface calls to wrapped actual host objects, and then have my logic only interact with the interfaces, but :barf:

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

i like
» NaN === NaN
false
» var a = NaN; a === a
false

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

KidDynamite posted:

boss wants me to have real reason for wanting a normalized relational db even though we we need to emulate relationships in a schema-less db.

because you're not a loving idiot, that's why you want a normalized relational database

also at least some common "NoSQL" implementations turn out to be isomorphic to the relational algebra anyway, especially as used, just with worse performance and no ACID guarantees that a real relational database (even SQLite) can provide

there was a proof 5-6 years ago that I can't find now but I recall it being pretty straightforward

weird
Jun 4, 2012

by zen death robot
in lisp, eq compares object identity, but for numbers and characters the implementation is allowed to make copies whenever it's convenient for it, so for example

code:
(let ((x 1))
  (eq x x))
might return true or false

jesus WEP
Oct 17, 2004


KidDynamite posted:

where can i learn more about schema-less databases?
take a good hard look in the bowl before you flush

eschaton
Mar 7, 2007

Don't you just hate when you wind up in a store with people who are in a socioeconomic class that is pretty obviously about two levels lower than your own?

weird posted:

in lisp, eq compares object identity, but for numbers and characters the implementation is allowed to make copies whenever it's convenient for it, so for example

code:

(let ((x 1))
  (eq x x))

might return true or false

now explain the difference between eq, eql, equal, and equalp

then grab the new update to Mezzano and start hacking on a brand new Lisp Machine for your x86-64 virtual machine of choice (as long as it does virtio networking)

a good starting point would be to add system & site init files and then, more ambitiously, a system mode line at the bottom, like the old Lisp Machines had, instead of the random bars of color at the very top of the screen to say what the system is doing

(seriously, Mezzano is cool and good for how small it is, and it's worth reading some of the code just to see how little it takes to put together a working OS in a high level language)

eschaton fucked around with this message at 09:53 on Mar 24, 2016

30 TO 50 FERAL HOG
Mar 2, 2005



lots of infernal stupid parenthesis

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


BiohazrD posted:

because it doesn't make sense?

like apple + potato doesn't equal apple

anything / 0 is NaN

infinity + 1 is still infinity

an int + a thing that is not an int isn't an int

although perhaps you are a php developer

null should have 0 operations defined for it. it is an instance of a pseudo bottom type and quite frankly even implicitly converting it to another type really sucks.

but that behavior is way more sane than 0 + null = null.

also, null + 0 and 0 + null in c# is an int.

code:
using System;

public class Test
{
    public static void Main()
    {
        int x = null + 5; //null is obviously implicitly converted to 0 here
	int? y = null;
	var z = x + y;
        Console.WriteLine(x); //prints 5, not null
	Console.WriteLine(y); //prints nothing, null
	Console.WriteLine(z == null); //prints true, z is null.
	Console.WriteLine(((Nullable<int>)null) + 5); // null
    }
}
so it looks like c# implicitly casts null to a value type if it is a literal in a expression with a value type (like the definition of x above). one nice thing about c# compared to java is that you can't explicitly cast a null into a primitive (or value) type. it seems that the only time 0 + null = null is true is when null is a Nullable<int> type, which makes sense since Nullable is fairly similar to Option/Maybe types.

Condiv fucked around with this message at 11:38 on Mar 24, 2016

Jabor
Jul 16, 2010

#1 Loser at SpaceChem

Condiv posted:

null should have 0 operations defined for it. it is an instance of a pseudo bottom type and quite frankly even implicitly converting it to another type really sucks.

but that behavior is way more sane than 0 + null = null.

these two sentences are contradictory? {val} + ⊥ becomes ⊥ for all {val}, what other implementation makes the remotest sense?

if you must, you can look at it as + not being defined for ⊥, so the overall statement also evaluates as ⊥

ErIog
Jul 11, 2001

:nsacloud:

Condiv posted:

but that behavior is way more sane than 0 + null = null.

How? Null is not zero. It should error out like divide by zero or a null pointer. I just spent like a day of work trying to trace bugs like this in code where poo poo like NaN, null, and Infinity gets silently massaged to acceptable input and it's a loving nightmare. If you're trying to use a null for anything the program should crash hard, something bad has happened. The language deciding that null means zero is the loving worst case. The language doesn't know why that value is null so massaging it to zero is making a loving big assumption without any information.

Null is not some innate property of the universe. Null is chosen as a returnable value by programmers for some specific purpose, and massaging it to zero stomps all over whatever message was trying to be sent. The language doesn't have enough information to make the decision that null should mean 0 so it shouldn't be making that decision.

At some point in the last couple decades idiots decided a program crashing was the worst sin ever, and instead of having people write better code they decided it was better for poo poo to plod along with unpredictable state. That's stupid. That leads to data corruption. That leads to stack traces that are functionally meaningless because you only find out something got nulled or NaN'ed when you use a function that doesn't massage things to a proper type.

ErIog fucked around with this message at 11:46 on Mar 24, 2016

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


Jabor posted:

these two sentences are contradictory? {val} + ⊥ becomes ⊥ for all {val}, what other implementation makes the remotest sense?

if you must, you can look at it as + not being defined for ⊥, so the overall statement also evaluates as ⊥

is there a language where you can actually do {val} + ⊥ ? and an implementation that makes sense is to not be able to instantiate the bottom type or have a literal representing the bottom type.

Condiv fucked around with this message at 11:49 on Mar 24, 2016

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


ErIog posted:

How? Null is not zero. It should error out like divide by zero or a null pointer. I just spent like a day of work trying to trace bugs like this in code where poo poo like NaN, null, and Infinity gets silently massaged to acceptable input and it's a loving nightmare. If you're trying to use a null for anything the program should crash hard, something bad has happened. The language deciding that null means zero is the loving worst case. The language doesn't know why that value is null so massaging it to zero is making a loving big assumption without any information.

Null is not some innate property of the universe. Null is chosen as a returnable value by programmers for some specific purpose, and massaging it to zero stomps all over whatever meaning the programmer might have intended. The language doesn't have enough information to make the decision that null should mean 0 so it shouldn't be making that decision.

At some point in the last couple decades idiots decided a program crashing was the worst sin ever, and instead of having people write better code they decided it was better for poo poo to plod along with unpredictable state. That's stupid. That leads to data corruption. That leads to stack traces that are functionally meaningless because you only find out something got nulled or NaN'ed when you use a function that doesn't massage things to a proper type.

i agree it should error out because null is not an int and cannot be represented by an int. but both C# and java implicitly convert null into a value type if you use it as a literal in an expression. that behavior is saner than returning null from the expression null + 0, but it still sucks.

Nullable<int> + int = Nullable<int> makes sense though, as well as (int?) null + 5 == (int?) null.

Condiv fucked around with this message at 11:53 on Mar 24, 2016

ErIog
Jul 11, 2001

:nsacloud:

Condiv posted:

i agree it should error out because null is not an int and cannot be represented by an int. but both C# and java implicitly convert null into a value type if you use it as a literal in an expression. that behavior is saner than returning null from the expression null + 0, but it still sucks.

0 + null = null is certainly passing the buck, but it seems way more defensible than 0 + null = 0. You still haven't explained why you think the former is the saner choice.

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


ErIog posted:

0 + null = null is certainly passing the buck, but it seems way more defensible than 0 + null = 0. You still haven't explained why you think the former is the saner choice.

yes i have. null as a literal has no operations on it and cannot be added to 0. that leaves you with the option of implicitly casting null as an int (a bad decision, but one C# takes), or throwing a compile time error (a better idea imo).

0 + (int?) null = (int?) null in c#, and that makes sense because Nullable<int> behaves like a Maybe or Option type with an implicit map function.

code:
int? x = null;
int y = 5;

Console.WriteLn(x + y == x) //true
is functionally equivalent to

code:
val x: Option[Int] = None
val y = 5

println(x.map(_ + y) == x) //true

Condiv fucked around with this message at 12:20 on Mar 24, 2016

Phone
Jul 30, 2005

親子丼をほしい。
c# is just paving the way for future quantum programmers.

Mahatma Goonsay
Jun 6, 2007
Yum
my life as a null0

qntm
Jun 17, 2009

Wheany posted:

i like
» NaN === NaN
false
» var a = NaN; a === a
false

that's just a perfectly normal feature of IEEE 754

Bloody
Mar 3, 2013

NaN isnt anything and should not be equal to anything

null is a thing that should be equal only to itself

0 + null should be an exception

0 + an int? where the int? does not contain a value idk im not super bothered if + is defined on that but it still feels like it should return an int? that does not contain a value

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

qntm posted:

that's just a perfectly normal feature of IEEE 754

i know, but it sure as hell isn't intuitive

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
i used to work on a huge C codebase from the 90s that was originally on SPARC that depended on x / 0 == 0.

it was a bitch to port to x86, lemme tell you

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


Bloody posted:

NaN isnt anything and should not be equal to anything

null is a thing that should be equal only to itself

0 + null should be an exception

0 + an int? where the int? does not contain a value idk im not super bothered if + is defined on that but it still feels like it should return an int? that does not contain a value

:agreed:

Condiv
May 7, 2008

Sorry to undo the effort of paying a domestic abuser $10 to own this poster, but I am going to lose my dang mind if I keep seeing multiple posters who appear to be Baloogan.

With love,
a mod


CRIP EATIN BREAD posted:

i used to work on a huge C codebase from the 90s that was originally on SPARC that depended on x / 0 == 0.

it was a bitch to port to x86, lemme tell you

:eyepop:

CRIP EATIN BREAD
Jun 24, 2002

Hey stop worrying bout my acting bitch, and worry about your WACK ass music. In the mean time... Eat a hot bowl of Dicks! Ice T



Soiled Meat
it also depended on weird compiler/linker behavior such as allowing duplicate symbols to be linked together (and randomly picking one of them to use in the compilation unit).

instead of making a library it just linked .o files in at random from all over the project or just copy/pasted functions randomly into other files.

Brain Candy
May 18, 2006

qntm posted:

that's just a perfectly normal feature of IEEE 754

bs, only because its servicable to some degree unlike sNaN

if signaling NaNs were a thing that was guaranteed to work well, do you really think they'd be be turned off in any non p-lang by default?

quiggy
Aug 7, 2010

[in Russian] Oof.



:suicide:

Adbot
ADBOT LOVES YOU

MononcQc
May 29, 2007


That's IEEE Standard 754 on floating points.

±∞ × 0 => NaN
±nonZero ÷ ±0 => ±∞

Not a javascript horror.

  • Locked thread