<FromGitter>
<HertzDevil> however the crystal compiler relies on the external name (not internal) of the splat parameter being empty to determine whether that param can take any args
<FromGitter>
<oprypin:matrix.org> oh that should be fixed
<FromGitter>
<asterite> Probably an oversight but it's not clear to me what's the issue
<FromGitter>
<oprypin:matrix.org> interesting, for `def f("" x); end` the doc signature that's generated is `def f(_ x) `
<FromGitter>
<oprypin:matrix.org> @HertzDevil: but it's impossible for the splat arg to have an external name so it's fine
yxhuvud has joined #crystal-lang
<FromGitter>
<oprypin:matrix.org> how to get an array `[1,1,2,2,4,4]` from an array `foo=[1,2,4]`
<FromGitter>
<oprypin:matrix.org> i have `Spec.before_each do WebMock.reset` and i check that it's called the same number of times as there are total examples
<FromGitter>
<Blacksmoke16> is there a specific test that fails?
<FromGitter>
<oprypin:matrix.org> @Blacksmoke16: no, --order=random and random fails
<FromGitter>
<oprypin:matrix.org> `by_branch / ""` and `dash_by_branch / with .yml` pop up (almost?) always
<FromGitter>
<jrei:matrix.org> hum you have 2 before_each
<FromGitter>
<erdnaxeli:cervoi.se> funny that {{yield}} works if a block is provided or not (it actually helps)
<FromGitter>
<Blacksmoke16> mhm
<FromGitter>
<jrei:matrix.org> what's the diff between `before_each` and `Spec.before_each`
<FromGitter>
<oprypin:matrix.org> have to run `make test` once first
<FromGitter>
<jrei:matrix.org> my bad, I too used to `crystal spec` :)
<FromGitter>
<oprypin:matrix.org> not your bad at all
<FromGitter>
<jrei:matrix.org> I got no issues
<FromGitter>
<jrei:matrix.org> I ran it, say 5 times
<FromGitter>
<jrei:matrix.org> 20 times :)
<FromGitter>
<oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): um did u check out the particular commit
<FromGitter>
<jrei:matrix.org> ha, miss it
<FromGitter>
<jrei:matrix.org> got an error yes
<FromGitter>
<jrei:matrix.org> I continue the discussion in PM
<FromGitter>
<oprypin:matrix.org> it's really very simple - just because I *ever* stub a call to a different value, it fails
<FromGitter>
<oprypin:matrix.org> *no problem whatsoever in Crystal, everything is good*
<FromGitter>
<oprypin:matrix.org> just me being a dummy because my application has a cache and *it* chooses not to re-fetch the same url although webmock would've correctly stubbed it to a different value
<FromGitter>
<oprypin:matrix.org> thanks j8r (https://matrix.to/#/@jrei:matrix.org) for help
<FromGitter>
<oprypin:matrix.org> mm guess my strategy of pushing a binary from one archlinux to another isn't so rock-solid
<FromGitter>
<oprypin:matrix.org> just got hit by a `/usr/lib/libc.so.6: version `GLIBC_2.33' not found`
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
FromGitter has joined #crystal-lang
<FromGitter>
<Blacksmoke16> could just compile it statically first no?
<FromGitter>
<oprypin:matrix.org> could i, though?
<FromGitter>
<Blacksmoke16> built it in alpine linux via docker and tada
<FromGitter>
<jrei:matrix.org> oprypin (https://matrix.to/#/@oprypin:matrix.org): arch linux is not rock solid by essence
<FromGitter>
<oprypin:matrix.org> yes it is 😠
<FromGitter>
<jrei:matrix.org> even though the error is not related here
<FromGitter>
<jrei:matrix.org> it is a rolling release distribution, things may breack
<FromGitter>
<oprypin:matrix.org> anyway regarding the angry emoji - im joking ofc
<FromGitter>
<jrei:matrix.org> I find Alpine KISSer than Arch :D
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU__ has joined #crystal-lang
DTZUZU__ is now known as DTZUZU
<FromGitter>
<jrei:matrix.org> you could add a CD with GitHub Actions
DTZUZU_ has quit [Ping timeout: 265 seconds]
<FromGitter>
<jrei:matrix.org> generate a new priv/pub SSH key, then a the private key as a secret
<FromGitter>
<jrei:matrix.org> the static binary will be deployed automatically. If you like, you could even keep the service restart manual if you want more safety
<FromGitter>
<oprypin:matrix.org> yeaaa i don't trust that
<FromGitter>
<jrei:matrix.org> trust what?
<FromGitter>
<oprypin:matrix.org> GitHub with my machine
<FromGitter>
<jrei:matrix.org> trust GitHub to deploy a trustworthy binary, or working one?
<FromGitter>
<erdnaxeli:cervoi.se> in case I am doing a library with `test`, I would think this is a bug. It means I have to write exhaustive testing to catch it.
<FromGitter>
<Blacksmoke16> you're using exhaustive case so thats the expectation yes
<FromGitter>
<erdnaxeli:cervoi.se> but my case in not exhaustive, the test for `D` is missing
<FromGitter>
<Blacksmoke16> it works without the D type since unused types/methods are removed
<FromGitter>
<Blacksmoke16> assuming its not used at all
<FromGitter>
<erdnaxeli:cervoi.se> it means my method is actually defined for Union(B, C), not A
<FromGitter>
<erdnaxeli:cervoi.se> like if the type inference system has priority over my type anontation
<straight-shoota>
what exactly would you expect?
<FromGitter>
<erdnaxeli:cervoi.se> I would expect the compiler to tell me that my case is missing `A` and `D` conditions
<FromGitter>
<erdnaxeli:cervoi.se> because I tell it that I want test to accept `A`, and my case is obviously wrong with that type of argument
<FromGitter>
<Blacksmoke16> if i had to guess the compiler is smart enough to know the method *is* exhaustive based on all the invocations of the method
<FromGitter>
<erdnaxeli:cervoi.se> yeah but I don't want that
<FromGitter>
<erdnaxeli:cervoi.se> maybe someone will use my lib and write another invocation
<FromGitter>
<erdnaxeli:cervoi.se> I know I can write a test for that, but that means I can't trust the compiler on that
<straight-shoota>
type restrictions on method arguments don't work like that
<FromGitter>
<Blacksmoke16> if the user creates another subtype it would also break down as you cant just add another `in` clause to the case
<straight-shoota>
`def test(a : A)` makes sure that `a` matches the restriction `A`
<straight-shoota>
but it doesn't cast the argument to that type
<straight-shoota>
you can cast to `A` explicitly using `a = a.as(A)`
<FromGitter>
<erdnaxeli:cervoi.se> but then my case would only match `in A`, right?
<FromGitter>
<erdnaxeli:cervoi.se> what I would like is the compiler to tell me "ok you want to accept any A, but your case isn't actually exhaustive with any A"
<FromGitter>
<erdnaxeli:cervoi.se> there is still the case that Blacksmoke16 raised
<FromGitter>
<Blacksmoke16> whats the exact usecase here?
<straight-shoota>
yes, then you need to cover A as well
<FromGitter>
<erdnaxeli:cervoi.se> I don't have tihs exact usecase actually, I was just testing the behavior of crystal and got suprised ^^"
<straight-shoota>
you can't really do this
<straight-shoota>
maybe with sealed types it could work
<FromGitter>
<erdnaxeli:cervoi.se> my real use case will match the result of à from_json with use_json_discriminator, so I guess as it can actually return all the types, it will works as expected
<FromGitter>
<erdnaxeli:cervoi.se> yeah but I understood sealed types are not a thing in crystal :p
<straight-shoota>
maybe at some point...
<straight-shoota>
I don't think it would work like you expect with deserialized values.
<straight-shoota>
If the return type is something like B | C | D the compiler merges that to A+
<straight-shoota>
so you would still have to cover `A` even if the parent type is never valid
<FromGitter>
<erdnaxeli:cervoi.se> the case only see "A"
<FromGitter>
<HertzDevil> like i said we should support devirtualized types in exhaustive cases
<FromGitter>
<HertzDevil> but in the original example you still have to cover A and only A, because it isn't abstract
<FromGitter>
<erdnaxeli:cervoi.se> right
_ht has quit [Remote host closed the connection]
<FromGitter>
<jrei:matrix.org> I hope one day to have a restricted subset of Crystal which allows improved compile times
<oprypin>
thats #nim
<FromGitter>
<jrei:matrix.org> I don't really think it is, on the syntax POV
<FromGitter>
<jrei:matrix.org> I find Crystal a bit easier to start with, because more procedural/less functional
<FromGitter>
<asterite> I need to try nim again...
<FromGitter>
<jrei:matrix.org> 1) 8k issues on Nim O.o
<FromGitter>
<jrei:matrix.org> That's strange, perhaps they didn't clean them up
<FromGitter>
<jrei:matrix.org> The language sounds simpler overall
<FromGitter>
<oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): haha no its surface is like 5x bigger
<FromGitter>
<jrei:matrix.org> Ha? I looked at some code in the compiler
<FromGitter>
<jrei:matrix.org> At least, the most used constructs are quite narrow there
<FromGitter>
<jrei:matrix.org> A least, for proc, it is used in place of `def`, `Proc`, proc literal, and perhaps block, and maybe more
<FromGitter>
<jrei:matrix.org> Their are lots of keywords by the way
<FromGitter>
<asterite> j8r you should check how many open bugs Java or C# have :-) . Bug count only talks about language popularity
<FromGitter>
<asterite> @HertzDevil yeah, devirtualizing types for sealed types is a good idea... but for example for the compiler it would maybe also be nice to say the hierarchy is sealed, but then the compile times go to the root... well, to the chimney I guess
<FromGitter>
<jrei:matrix.org> Yeah, but what's strange Crystal lools more popular
<FromGitter>
<HertzDevil> no it should be possible to use devirtualized types even for non-sealed types
<FromGitter>
<asterite> How?
<FromGitter>
<jrei:matrix.org> Crystal has more stars, but is younger, that may be a reason too
<FromGitter>
<asterite> I think you mentioned that the compiler knows all types before checking exhaustiveness... but the point is that if you do `case ... in` with a hierarchy you are using and everything compiles fine... imagine this is a library. Someone using the library subclasses a type and suddenly the code in the lib doesn't compile anymore. The sealed annotation would be there to say "this is really not meant to be
<FromGitter>
... subclassed"
<FromGitter>
<asterite> I don't think stars correlate to popularity
<FromGitter>
<jrei:matrix.org> oprypin (https://matrix.to/#/@oprypin:matrix.org): so why you said nim if its surface is 5x bigger than Crystal? It can't be a subset 🤔
<FromGitter>
<oprypin:matrix.org> it just has more features all over the place
<FromGitter>
<oprypin:matrix.org> more you need to know about. and more to memorize because intuition won't help you
<FromGitter>
<HertzDevil> but if it breaks it, well, breaks
<FromGitter>
<HertzDevil> it happens to non-hierarchies too like that `TupleInstanceType::Index` i just added
<FromGitter>
<HertzDevil> the only difference is where the error is reported
<FromGitter>
<HertzDevil> you shouldn't need a sealed annotation at all for the devirtualized semantics
<FromGitter>
<asterite> To realize how far we've come with intuitiveness in programming languages I recommend writing a real world application in Haskell :-)
<FromGitter>
<alexherbo2> javascript can pass hashes like `{ command, args, input }`, instead of `{ command: command, args: args, input: input }`
<FromGitter>
<Blacksmoke16> There isn't
<FromGitter>
<HertzDevil> that sounds like a counterfeature
<FromGitter>
<HertzDevil> at the same time it sounds like something you could do yourself with macros
<FromGitter>
<oprypin:matrix.org> @HertzDevil: no it's a very good feature
<FromGitter>
<oprypin:matrix.org> overall it can be even a benefit because it encourages you to use named args whereas otherwise you wouldn't bother writing it out
<FromGitter>
<Daniel-Worrall> The real answer is to do TDD and unit testing
<FromGitter>
<HertzDevil> then you can do `**named(...)`
<FromGitter>
<HertzDevil> making it a language feature means we have to invent new syntax rules for it
<FromGitter>
<oprypin:matrix.org> who says we have to do anything
<FromGitter>
<oprypin:matrix.org> you said ⏎ ⏎ > that sounds like a counterfeature
<FromGitter>
<oprypin:matrix.org> and no, it isn't. arguing only that part
<FromGitter>
<HertzDevil> i'm referring to "javascript overloading the `{...}` syntactic form to refer to this kind of objects" being a counterfeature in case i'm not clear
<FromGitter>
<oprypin:matrix.org> me too
<FromGitter>
<HertzDevil> you're suggesting it's a good feature, and i suggest it doesn't have to be a "feature" at the language level since the `named` macro does the same
<FromGitter>
<HertzDevil> it's a good use case sure
<FromGitter>
<HertzDevil> it could be a stdlib feature too (which i consider to be distinct from language features but some will disagree)
<FromGitter>
<Daniel-Worrall> Nobody is talking about adding it to crystal, Hertz
<FromGitter>
<Daniel-Worrall> It's a great feature, and good for javascript for having it
<FromGitter>
<HertzDevil> and now i am
<FromGitter>
<asterite> The other day I realized Ruby doesn't have any kind of syntax sugar, while Crystal and many other language have
<FromGitter>
<HertzDevil> and i now claim that we shouldn't support that `{...}` short form in crystal whether or not it makes sense in javascript
<FromGitter>
<oprypin:matrix.org> ruby doesnt have syntax sugar? what was `foo(x: y)` if not syntax sugar
<FromGitter>
<asterite> Oh, you mean that it's a way to pass a Hash?
<FromGitter>
<asterite> Yeah... Though in recent versions that might not be the case if the receiver has keyword arguments... No idea how that's implemented
<FromGitter>
<asterite> But for example I proposed to add &.foo to Ruby and they didn't accept it because & is not an expression
<FromGitter>
<asterite> In Crystal that's just syntax sugar for something you can write in a different way... And I don't think Ruby has a lot of that
<FromGitter>
<oprypin:matrix.org> @HertzDevil: the macro substitute is going to be quite hindered by https://carc.in/#/r/af1f
<FromGitter>
<oprypin:matrix.org> can write `f(x, y = 1 + 2, z)` though *hiss*