Spyke

Syndicated from the fediverse. Read and engage on the original instance.

View original on lemmings.world

39 replies

lemmy.zip

Semantic satiation. Or whatever it's called, i think ive officially lost it after reading this

54
aussie.zone

Is "main" a valid Java identifier?

::: spoiler yes

package main;

public class main {

    static main main;
    String Main;

    main(String main) {
        Main = main;
    }

    main(main main) {
        System.out.println(main.Main);
    }

    main main(main main) {
        return new main(main);
    }

    public static void main(main...Main) {
        main:
        for (main main : Main) {
            main = (main instanceof Main) ? new main(main): main.main(main);
            break main;
        }
    }

    public static void main(String[] args) {
        main = new main("main");
        main.main(main, main);
        main = main.new Main(main) {
            main main(main main) {
                return ((Main)main).main();
            }
        };
        main.main(main);
        main.main(main,main);
    }

    abstract class Main extends main {
        Main(main main) {
            super("main");
        }

        main main() {
            main.Main = "Main";
            return main;
        }
    }
}

:::

47
lemmy.dbzer0.com

I can see how this may be useful. My understanding is that this is go lang and the person created a wrapper type UUID and this function takes the go standard library uuid.UUID and returns the wrapped UUID.

The wrapped UUID could be useful as you can then define methods for it like toInt() or something to make it implement some ID interface you have set up. It's a common pattern in go to create a thin wrapper around an imported type so you can implement all the methods required for some interface you defined. It does make naming those thin wrappers hard because what are you supposed to name the struct that just contains a uuid?

22

Yep, that person would be me and that's exactly what I was doing, just found it funny that there was so many uuids in the piece of code.

Originally the function was named FromUuid but I couldn't resist renaming it to make it even better.

17

I've read so many tutorials like this. func Func Myfunc()

If you write textbooks like this you and your family should be boiled in sewage.

10
lemmy.world

If this was C:

#define uuID func
#define uuiD return
7

A colleague wrote Java style Python. SomethingDispatcher().dispatch() all the way. It's a mess. Poor guy was thrown into the deep end and left alone for a year. I don't blame him for the outcome.

Meanwhile, functools.partial is one of my favorite tools. I wrote a whole SCADA system in which the initialization just builds data pathways using functools.partial so that incoming event callbacks can be handled with all necessary resources already in scope. Any missing data is made apparent at init, not at event time. It's fast and stable (and I'm pretty proud of it lol).

1
merereply
lemmy.blahaj.zone

same - i think it's because the image is blocked in the UK because of the online safety act. Try using a VPN and see if that helps

1
programming.dev

The feeling you get when searching your codebase for references to your "uid" variable but this cheeky boy keeps popping up.

3

i've now read UUID so many times i'm starting to think it's some kind of sex disease

3
lemmings.world

That must one awkward conversation... "Can you explain where did you get the uuid from?"

2
lemmy.zip

Shouldnt it be return UUID { uuid: uuid.uuid } ?

I think it would make more sense AND more uuid per UUID

1
lemmings.world

The first UUID is a local type, the second is the name of an embedded struct, the third is the name of the variable.

The struct looks something like this (writing this on my phone)

type UUID struct { uuid.UUID }

So, basically, this is a custom wrapper for a third party UUID implementation.

3

I'm assuming it's a map/dictionary notation here, rather than a type hint

1

You reached the end