Programming thread

  • Want to keep track of this thread?
    Accounts can bookmark posts, watch threads for updates, and jump back to where you stopped reading.
    Create account
Operator overloading is a spook. Operators are a spook. They do not semantically exist and languages syntactically pretend they do exclusively to their own detriment. I will not elaborate.
 
Operator overloading is a spook. Operators are a spook. They do not semantically exist and languages syntactically pretend they do exclusively to their own detriment. I will not elaborate.
Operator overloading is useful for shit like vector math.
I like how f# does it. You can just define your own functions that work like infix operators. for example
Code:
open System

let (<|>) a b = //a function to get the distance between two points
    Math.Sqrt (((fst a - fst b) ** 2.0) + (snd a - snd b) ** 2.0)
    
    
let res =
    (1.2,3.4) <|> (5.6,7.8)

Or using computation expressions to define local keywords that can be just about anything, for example, from the saturn framework:
Code:
let notFoundHandler =
    pipeline {
        set_status_code 404
        plug htmlView (ErrorPageFunction 404)
    }

let someMiddleware next ctx =
    //do some logging
   let r =
      router {  //this matches routes with "/forwardstuff" already cut out
        get "/" (htmlView (Index ctx)) // "/forwardstuff/"
        get "/qwert" (htmlView (Index ctx)) // "/forwardstuff/qwert"
      }
   //more logging
   r next ctx


let webapp =
    router {
        get "/discord" (redirectTo true discordlink)
        forward "/forwardstuff" someMiddleware
        get "/abc" (htmlString someHTMLFile)
        get "/def" (htmlView SomeServerSideRenderedStuff)
        post "/login" (htmlView loginFunction)
        get "/account" (htmlView accountPage)
        delete "/account" (htmlView deleteAccountFunction)
        not_found_handler notFoundHangler
    }
 
I like how f# does it. You can just define your own functions that work like infix operators. for example
Code:
open System

let (<|>) a b = //a function to get the distance between two points
    Math.Sqrt (((fst a - fst b) ** 2.0) + (snd a - snd b) ** 2.0)
   
   
let res =
    (1.2,3.4) <|> (5.6,7.8)

Or using computation expressions to define local keywords that can be just about anything, for example, from the saturn framework:
Code:
let notFoundHandler =
    pipeline {
        set_status_code 404
        plug htmlView (ErrorPageFunction 404)
    }

let someMiddleware next ctx =
    //do some logging
   let r =
      router {  //this matches routes with "/forwardstuff" already cut out
        get "/" (htmlView (Index ctx)) // "/forwardstuff/"
        get "/qwert" (htmlView (Index ctx)) // "/forwardstuff/qwert"
      }
   //more logging
   r next ctx


let webapp =
    router {
        get "/discord" (redirectTo true discordlink)
        forward "/forwardstuff" someMiddleware
        get "/abc" (htmlString someHTMLFile)
        get "/def" (htmlView SomeServerSideRenderedStuff)
        post "/login" (htmlView loginFunction)
        get "/account" (htmlView accountPage)
        delete "/account" (htmlView deleteAccountFunction)
        not_found_handler notFoundHangler
    }
So much of programming language design is deciding if you’d rather imitate APL or lay down in the gutters with the rest of the swine.
 
Naturally, in Prolog, all operators can be redefined. https://www.swi-prolog.org/pldoc/man?section=operators

So much of programming language design is deciding if you’d rather imitate APL or lay down in the gutters with the rest of the swine.
Ew. No thanks. These days, for me, the fewer "operators", the better. I am just fine with straight S-expressions and I'd rather skip the parser overheads involved in supporting prefix, postfix, infix, ternary, etc. operators.
 
Naturally, in Prolog, all operators can be redefined. https://www.swi-prolog.org/pldoc/man?section=operators


Ew. No thanks. These days, for me, the fewer "operators", the better. I am just fine with straight S-expressions and I'd rather skip the parser overheads involved in supporting prefix, postfix, infix, ternary, etc. operators.
You will never have a one line implimentation of Conway’s Game of Life. You will forever be inferior. Cope and sneed
 
the best and worst part of C++ is possibly templates because while you can do amazing things with them its also incredibly easy to hang yourself due to complications from both your own stupidity and how they are implemented between compilers. The worst part about hanging yourself with the errors is that they can resolve themselves in system headers.

Edit: the even worst part is there is not way to easily premptively evaluate the templates to know ahead of time what they will turn into so when they break you are regularly fucked.
 
Last edited:
You will never have a one line implimentation of Conway’s Game of Life. You will forever be inferior. Cope and sneed

>codegolf is how languages are compared

APL is code for acolytes of Bertrand Russell who have never once needed to read the code they're responsible for
 
In Haskell you can just put whatever unicode combination as infix operator.
a ⋅ b = [...] is valid Haskell. So is a <⋅> b = [...]
Raku permits similar daemonic faggotry:
>codegolf is how languages are compared

APL is code for acolytes of Bertrand Russell who have never once needed to read the code they're responsible for
Code:
'Tis the dream of each programmer,
Before his life is done,
To write three lines of APL,
And make the damn things run.
 
programming Nirvana
No thanks, I'll take my future with Mr. God and HolyC.

A helpful table of APL symbols
2025-12-30-152247_887x1916_scrot.png
 
Back
Top Bottom