How can we increase adoption of c/c++ alternatives?



  • @EvanED said:

    What's so special about one?

    It's the multiplicative identity, the first natural number, and the difference between consecutive integers.


  • Fake News

    It's also the loneliest number that you'll ever do.



  • Two can be as bad as one.
    It's the loneliest number since the number one.
    Filed under: rhymes 'one' with 'one', is lame


  • Banned

    @Buddy said:

    Why does Rust require a comma to disambiguate a single value ((x,)) from a single value ((x))? Wouldn't it make more sense to make those two things semantically equivalent?

    Do I look like Rust compiler developer? If it bugs you that much, file a bug. Why would you ever write "(x,)" anyway!?



  • Listen, such clunky 1-tuple syntax is an embarrassment to the human race, and until they get this shit sorted out, nobody is going to take their language seriously. :stamps_foot:



  • @Buddy said:

    clunky... syntax is an embarrassment... nobody is going to take their language seriously.

    Never stopped C++ :<lolz>P


  • Banned

    It's not an embarassment if no one is using it. Nobody complained about function-local function declarations in C until it conflicted with C++'s object construction syntax.



  • @tar said:

    A C-language-only implementation of <stdarg.h> would be... fairly interesting, I think.

    Variable arguments are a language feature. But the whole idea behind putting the reading the reading part in a header is that it actually is possible to implement it in C. va_list is basically a pointer to the argument and va_arg casts it to appropriate type and increments it by size of the type rounded up to multiple of size of int. Gcc implements it as builtins though.

    @antiquarian said:

    fi

    In pseudocode in programming lessons we also used elihw to end while and when we occasionally used for loop also rof.

    @EvanED said:

    Ignore order for a second and just imagine mathematical sets.

    Think Cartesian products instead. That's what tuples are and there is no single-element Cartesian product. I.e. if

    @Buddy said:

    type((1,2,3)) [is] int * int * int

    then type((1,)) is int and ((1)) and ((1,)) become the same.

    It's possible to have singlets as separate types or not and each option has it's advantages.


  • Banned

    @Bulb said:

    In pseudocode in programming lessons we also used elihw to end while and when we occasionally used for loop also rof.

    And that's why braces are good for beginners - a clear indication of beginning and end, without making up barely pronouncable words the students will make fun of instead of trying to understand.

    @Bulb said:

    It's possible to have singlets as separate types or not and each option has it's advantages.

    I'm still waiting for a realistic example where (1,) syntax would be useful and being a separate tuple type would be problematic.



  • In Python and Rust, you have a problem where (1, 2) is a tuple but (1) is not—you need (1,) to create such a tuple—which is unintuitive and easy to forget. It makes sense in Python, where tuples are containers that can, for instance, be iterated over, and where duck-typing would make disambiguating 1-element tuples from the objects inside them awkward if they were to special-case the 1-tuple. In Rust, where tuples are purely syntactic, and there is no overlap between what you can do with a tuple and what you can do with an object, the choice is baffling.

    In Swift, where tuple handling is closer to Rust than Python, there is no 1-tuple, but all non-tuple objects have a .0 property that simply returns the object itself. That's ok, I guess, but it would be a lot cooler if Rust were able to see (1) and use type inference to detect whether an integer or tuple was intended. I'm sorry if my trollish attitude came off as an actual criticism of Rust; really, I was just interested to know if there was any technical reason that you knew of for that particular design decision.


  • Banned

    @Buddy said:

    I was just interested to know if there was any technical reason that you knew of for that particular design decision.

    YAGNI and KISS, I think. Rust devs are the guys who got rid of void/null/nil type in favor of zero-element tuple, after all. They hate special cases - there's an open PR for making a negative trait implementation so they can cut Send trait (that has no method, but indicates that object is safe to be used by multiple threads) out of core language and into library. The only syntactic sugar I'm aware of is "if let", and they only added it because it reduces line count in match-heavy (ie. typical Rust) code twofold - everything else is either a macro, a syntax extension (which is a macro too, actually), or core Rust syntax.

    Auto-destructuring single-element tuples would be pure syntactic sugar, and cases where it's actually useful are so rare it's not worth it.



  • Why are there 1-tuples at all then?


  • Banned

    By accident. Think of it as [](){}().



  • @Bulb said:

    we also used elihw to end while and when we occasionally used for loop also rof.

    We should just end the loops with the same keyword, only succeeded by a RTL override.



  • I just read an SO question where the answer was "tuple to list to tuple", I think that I may be done with Python.





  • Shall I post a picture of myself in a singlet?


Log in to reply