Conversation started Mar 21, 2023 at 9:44.
Mar 21, 2023 09:44
Random dumb idea for my practlang, what if in addition to ++ and -- you could do ** to multiply by 2 in place, // to divide by 2, and %% to mod 2
Makes sense.
@mousetail go further and make it so that all operators can do this
What other operators are there?
I guess bitwise ones but && and || already have another meaning
oof
Mar 21, 2023 09:49
Suppose they didn't though, what should the default right value be?
Bi-glyphs should be limited to the minimum
Also << and >> I guess, could be <<<< and >>>>
@mousetail depends on the operator.
For &&?
@mousetail Yes, and in general, such implicit arguments are just more to remember.
Mar 21, 2023 09:50
@mousetail Well what does & do
bitwise and
Just support var+=1 etc. for all operators and get rid of the strange 1-arg syntax
That would be the sane option though
> practlang
Practical languages should be sane, imho.
I'll probably not implement these things but theoretically how would they be used
Mar 21, 2023 09:51
@mousetail something that makes a number like 16 or 8 bits at most
@Adám my suggestion to make it for everything was mostly in jest anyway
I might make a fork of my practlang with lots of dumb useless stuff
esolang variation
APL doesn't have the var++ and ++var but all operators, even user-defined ones, can be used in the var f= arg syntax.
More languages should support that
It's really cool
Vyxal 3 has arg f#>var for it
Actually practically I might implement ???? that, for a type that implements default, assigns the default to a nullish value
Slightly hard to read, imo.
Should use instead of ??
Mar 21, 2023 09:57
@mousetail could I have an example? I'm not quite getting this
If myvar is a declared but unassigned boolean, myvar???? is equivalent to myvar=false
Oh that's cool
Why not just do it at variable creation though?
If myvar is num, then it becomes 0, if string, it becomes ""
@lyxal Maybe you're getting it from some external source.
Something I recently did in PHP, $arr??=[] except then you could write it shorter since arrays have a default value
But I don't see how this can work if everything isn't strongly typed.
Mar 21, 2023 10:01
But the default is already defined for the type
@Adám It is strongly typed
So not assigning a value should set the default at creation
This would redeclare a Option<T> as a T
@mousetail Can you import JSON?
There will probably be a standard library module for JSON yes
Mar 21, 2023 10:03
But how do you infer types?
@mousetail then use the default when getting the value
No need for an operator
E.g. what is the type of myvar = {foo:"bar"}.baz ?
A enum of all all possible JSON types, like rust
Though normally you'd load JSON into a predefined structure
But what does myvar???? do?
myvar in your example is not a Option<> so you couldn't use it
Mar 21, 2023 10:05
Will you have both var++ and ++var?
@mousetail So then how about myvar = Some({pretend this is json I'm on mobile}.baz)
@lyxal If the JSON enum defines a default value, that. So probably Some(JsonValue::null)
fair enough
a????????b should be valid syntax, right?
@Adám Yes
So you could do this:
if (value ????) {
    log_warning("value was null, corrected");
}
Mar 21, 2023 10:09
@Adám what would the b do?
@Adám It would fail the type checker since a???? is not nullable anymore, and ?? requires a nullable type
Oh.
@mousetail but what if it was a double nested option?
Hmmm true
Not that you'd probably see something like that in a sane production system
But still
Mar 21, 2023 10:11
Imagine a???????????? when unwrapping a tripple nested Option
It would greatly reflect the questions the programmer has as to why there's a triple nested option
Add (?n) syntactic sugar so (?6) means ??????
That would further encourage terrible practices, I love it
@Adám Go all the way and make that work for every operator and syntax
Yesss!!! I mean Ye(s3)(!3)
Mar 21, 2023 10:14
Then you could just remove normal addition, just do a(++b)
(n(o)100)100) - the screams of programmers seeing this syntax
3
Totally worth it btw
 
Conversation ended Mar 21, 2023 at 10:16.