News for hackers. Stuff that matters.
Re:Clojure vs. The Static Typing World by wellpast on Friday October 27, 2017 @12:41PM (#15569997)
Another way to think about this. When you and I are defining "plus" in this way, you may be thinking types (and how they are inferred and everything). I am simply saying I want "plus" semantics to be identical to "+"... If "+" is capable enough to add the String "one" and "two" together, I'll take it. If one of my users types in a roman numeral "I" and "+" yields wrong behavior (throws, or produces bad value), then I have to think about types. But maybe that never happens...

(I'm not saying this is how to code, but I'm clarifying that you don't have to think about types to get the semantics/precision. You just want to think about types, can't help thinking about types, or something else, you tell me.)

Re:Clojure vs. The Static Typing World by tome on Saturday October 28, 2017 @07:48AM (#15574830)
> When you and I are defining "plus" in this way, you may be thinking types

Nope. No thinking in types required there.

> I am simply saying I want "plus" semantics to be identical to "+".

Yup. And that's exactly what the code that Drup pasted does.

> If "+" is capable enough to add the String "one" and "two" together

Yup. And that's exactly what the code that Drup pasted will do.

Re:Clojure vs. The Static Typing World by wellpast on Saturday October 28, 2017 @03:20PM (#15576372)
I was simply responding to Drup's "the fact that types are dynamic doesn't mean you don't have to think about them"...

If you're telling me you don't have to think about types, then you and I are on the same page.

But it sounds like we're talking Haskell here, so afaik, somewhere Haskell is going to ask you to specify types so that it can complete its type-proof (i.e., compile.)

If you're saying No, Haskell doesn't need that, then I'm afraid you have a dynamic language on your hands.

Re:Clojure vs. The Static Typing World by tome on Saturday October 28, 2017 @05:49PM (#15576869)
Where did I specify types here?

    Prelude> myfun x y = x ^ 2 + 2 * y * x - y ^ 2
    Prelude> myfun 3 6
    9
Re:Clojure vs. The Static Typing World by wellpast on Saturday October 28, 2017 @06:51PM (#15577088)
They are specified in the definition of the operators. Define a new operator '%' that concatenates two numbers together and then show me how in Haskell you would do:

   myfun x y = x ^ 2 % 2 * y * x - y ^ 2
Re:Clojure vs. The Static Typing World by tome on Sunday October 29, 2017 @03:37AM (#15578369)
What does it mean to "concatenate two numbers together"?
Re:Clojure vs. The Static Typing World by wellpast on Sunday October 29, 2017 @11:06AM (#15579568)

  55 % 102 would produce 55102
I made it up.
Re:Clojure vs. The Static Typing World by tome on Sunday October 29, 2017 @06:57PM (#15582008)
And what does 55.1 % 102 produce? 1e-12 % 3i+12?

And if your answer is "I only need it to work on integers" then don't blame Haskell when I choose to specialise it to Int!

Re:Clojure vs. The Static Typing World by wellpast on Sunday October 29, 2017 @07:50PM (#15582251)
I'm a bad product manager. The % should round the value to a tenth and then concat.

This is a silly example, of course, but the real world isn't short on creativity/silliness.

Re:Clojure vs. The Static Typing World by tome on Monday October 30, 2017 @03:29AM (#15583542)
And for complex numbers?
Re:Clojure vs. The Static Typing World by wellpast on Monday October 30, 2017 @01:02PM (#15586725)
Precondition: complex numbers are not supported. Unspecified behavior.
Re:Clojure vs. The Static Typing World by tome on Monday October 30, 2017 @01:41PM (#15587142)
OK, then I choose to specialise to the type Double!