ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
<FromGitter> <renich_gitlab> OK. Thanks.
xybre has joined #crystal-lang
deavmi has quit [Ping timeout: 240 seconds]
deavmi has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
<FromGitter> <HertzDevil> is it intentional that the external name of a parameter can be the empty string?
chachasmooth has quit [Ping timeout: 256 seconds]
chachasmooth has joined #crystal-lang
chachasmooth has quit [Ping timeout: 272 seconds]
chachasmooth has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 2.9]
DTZUZU has joined #crystal-lang
chachasmooth has quit [Ping timeout: 240 seconds]
chachasmooth has joined #crystal-lang
<FromGitter> <HertzDevil> ```p :"" # => :```
<FromGitter> <HertzDevil> welp
Stephanie has joined #crystal-lang
Stephie has quit [Ping timeout: 258 seconds]
<FromGitter> <> cuz the way to call it is probably `f(**{"": x})`
<FromGitter> <> maybe?? lol it's probably possible to call the function, even
<FromGitter> <> how did you create the external name?
asterite has quit [*.net *.split]
bougyman has quit [*.net *.split]
Flipez has quit [*.net *.split]
repo has quit [*.net *.split]
FromGitter has quit [*.net *.split]
chachasmooth has quit [*.net *.split]
riffraff169 has quit [*.net *.split]
jrayhawk has quit [*.net *.split]
coderobe has quit [*.net *.split]
justinmcp has quit [*.net *.split]
deavmi has quit [*.net *.split]
fifr has quit [*.net *.split]
badeball has quit [*.net *.split]
holst has quit [*.net *.split]
jhass has quit [*.net *.split]
DeBot has quit [*.net *.split]
bougyman has joined #crystal-lang
Flipez has joined #crystal-lang
FromGitter has joined #crystal-lang
asterite has joined #crystal-lang
repo has joined #crystal-lang
deavmi has joined #crystal-lang
badeball has joined #crystal-lang
fifr has joined #crystal-lang
holst has joined #crystal-lang
chachasmooth has joined #crystal-lang
riffraff169 has joined #crystal-lang
coderobe has joined #crystal-lang
justinmcp has joined #crystal-lang
jrayhawk has joined #crystal-lang
jhass has joined #crystal-lang
DeBot has joined #crystal-lang
jhass has quit [Max SendQ exceeded]
jhass has joined #crystal-lang
_ht has joined #crystal-lang
yxhuvud has quit [Remote host closed the connection]
<FromGitter> <HertzDevil> ```def f("" x) ⏎ p x ⏎ end ⏎ ⏎ f("": 1) # => 1``` []
<FromGitter> <HertzDevil> no splats needed
<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> <> oh that should be fixed
<FromGitter> <asterite> Probably an oversight but it's not clear to me what's the issue
<FromGitter> <> interesting, for `def f("" x); end` the doc signature that's generated is `def f(_ x) `
<FromGitter> <> @HertzDevil: but it's impossible for the splat arg to have an external name so it's fine
yxhuvud has joined #crystal-lang
<FromGitter> <> how to get an array `[1,1,2,2,4,4]` from an array `foo=[1,2,4]`
<FromGitter> <> `.flat_map { |x| [x, x] }`
<straight-shoota> * 2) { |i| foo[i // 2] }
<FromGitter> <naqvis> ``````
<FromGitter> <> @naqvis: i think this is slightly worst than the example i already posted
<FromGitter> <> the other one is interesting for performance tho
<FromGitter> <naqvis> I thought intention was to seek different ways of doing the same thing :P
<straight-shoota> you could even get more performance with foo.unsafe_at(i // 2)
<FromGitter> <naqvis> ```code paste, see link``` []
<FromGitter> <> wow thanks ⏎ so nice to confirm my guess :D
<FromGitter> <> I hate that yaml serialization changes whith new versions
<FromGitter> <Blacksmoke16> oh?
<FromGitter> <> it highlights the fast that the yaml specification is complex, and not that robust
<FromGitter> <> for instance, with 0.2.5 serializing nil returns "---\n" and on 0.2.2 `"--- \n"`
<FromGitter> <Blacksmoke16> ah you mean `libyaml`
<FromGitter> <> libyaml version
<oprypin> that's on libyaml
<FromGitter> <> indeed
<FromGitter> <> mhm `%r( )` regex literal doesnt work inside macros
<FromGitter> <> Hi, can I call a macro inside another macro?
<straight-shoota> sure
<FromGitter> <> erdnaxeli ( you can *call* it but not use its """return value"""
<FromGitter> <Blacksmoke16> ^^
<FromGitter> <Blacksmoke16> i.e. "have another macro expand after the first"
<FromGitter> <> hmm
<FromGitter> <Blacksmoke16> related
<FromGitter> <> I want to do something like that:
<FromGitter> <> … which seems to work
<FromGitter> <Blacksmoke16> yes that the usecase that works fine
<FromGitter> <Blacksmoke16> the thing that issue is for is saw you have a somewhat complex macro you want to use in two other methods
<FromGitter> <Blacksmoke16> atm there isnt a way to keep your macros DRY, so need to duplicate everything
<FromGitter> <Blacksmoke16> say*
<FromGitter> <> but what I did allow me to DRY, no?
<FromGitter> <> I can use this one macro in many places
<FromGitter> <Blacksmoke16> i mean like this
<FromGitter> <> ok
<FromGitter> <> my usecase is simplier than that… so far :p
<FromGitter> <Blacksmoke16> like to share a value within a macro before it expands
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <> ok, why this one does not work?
<FromGitter> <> it's like it doesn't get that "two" is a macro
<FromGitter> <Blacksmoke16> where are you defining the `Outside` type?
<FromGitter> <Blacksmoke16> did you mean `struct {{}}`?
<FromGitter> <> oups, yes
<FromGitter> <> but I got the same error:
<FromGitter> <> just doing s/two/record/ works…
<FromGitter> <> ok found it, the inside argument was missing
<FromGitter> <Blacksmoke16> could just default it to `nil` or something
<FromGitter> <Blacksmoke16> and fwiw macros can use `{{yield}}`
<FromGitter> <Blacksmoke16> i.e. if you wanted to define methods within the type
<FromGitter> <> ok and now I have the same problem that in my actual code: works but does not
<FromGitter> <Blacksmoke16> you call macros like class methods
<FromGitter> <Blacksmoke16> `Test.two ...`
<FromGitter> <> ok I have to use inside two
<FromGitter> <Blacksmoke16> mmk
<FromGitter> <Blacksmoke16>,*properties)-macro isnt this essentially what you want?
<FromGitter> <> aaaa webmock in specs is killing me
<FromGitter> <> i have `Spec.before_each do ⏎ WebMock.reset` ⏎ and yet, it doesn't reset
<FromGitter> <Blacksmoke16> if you add a `puts` or something, is it getting called?
<FromGitter> <> oh wtf i think it's this
<FromGitter> <> aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
<FromGitter> <> how am i supposed to do scoped mocks
<FromGitter> <Blacksmoke16> but there are instance methods versions of those that are for a specific describe block
<FromGitter> <Blacksmoke16> i would have expected the class method version to be before *every* `it` block
<FromGitter> <Blacksmoke16> sure thats not the case?
<FromGitter> <> hm yea cannot reproduce
<FromGitter> <> @Blacksmoke16: in this example it looks like `record`, but actually I am doing more
<FromGitter> <Blacksmoke16> 👍 gotcha
<FromGitter> <> (sorry I was missing your message, my matrix client is kind of buggy)
<FromGitter> <> `{{yield}}` could actually help me a lot! I forgot about it but I already used it with `record`
<FromGitter> <Blacksmoke16> good to hear
<FromGitter> <> i need help
<FromGitter> <> ⏎ ⏎ why does this fail randomly?
<FromGitter> <> 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> <> @Blacksmoke16: no, --order=random and random fails
<FromGitter> <> `by_branch / ""` and `dash_by_branch / with .yml` pop up (almost?) always
<FromGitter> <> hum you have 2 before_each
<FromGitter> <> funny that {{yield}} works if a block is provided or not (it actually helps)
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <> what's the diff between `before_each` and `Spec.before_each`
<FromGitter> <> i would also like to know whats the diff
<FromGitter> <Blacksmoke16> the latter is before every `it` block, while the former is scoped to the `describe`/`context` block it's used in
<FromGitter> <> j8r ( check out
<FromGitter> <> ok!
<FromGitter> <> so maybe the before_each does not work properly with random, don't know
<FromGitter> <> that... could be it
<FromGitter> <> before_each will execute on all childs "it" and "describes" too I guess
<FromGitter> <> j8r ( no everything seems fine
<FromGitter> <> right
<FromGitter> <> no idea then; how it's failing
<FromGitter> <Blacksmoke16> does it consistently fail when using the same random seed?
<FromGitter> <> this add to execute once before all specs:
<FromGitter> <> (and below)
<FromGitter> <> yes
<FromGitter> <> that's quite a bad one but i'm sure it's not the cause
<FromGitter> <> I'll clone locally to try things
<FromGitter> <> ... ⏎ ⏎ > Error: Error opening file with mode 'r': 'style.css': No such file or directory
<FromGitter> <> > In src/ ⏎ > ⏎ > 622 | ctx.response << {{read_file(}}
<FromGitter> <> have to run `make test` once first
<FromGitter> <> my bad, I too used to `crystal spec` :)
<FromGitter> <> not your bad at all
<FromGitter> <> I got no issues
<FromGitter> <> I ran it, say 5 times
<FromGitter> <> 20 times :)
<FromGitter> <> j8r ( um did u check out the particular commit
<FromGitter> <> ha, miss it
<FromGitter> <> got an error yes
<FromGitter> <> I continue the discussion in PM
<FromGitter> <> it's really very simple - just because I *ever* stub a call to a different value, it fails
<FromGitter> <> *no problem whatsoever in Crystal, everything is good*
<FromGitter> <> 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> <> thanks j8r ( for help
<FromGitter> <> mm guess my strategy of pushing a binary from one archlinux to another isn't so rock-solid
<FromGitter> <> just got hit by a `/usr/lib/ 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> <> could i, though?
<FromGitter> <Blacksmoke16> built it in alpine linux via docker and tada
<FromGitter> <> 😩
<FromGitter> <> is my fastest growing (in stars) project :D ⏎ comparison graph (
teardown has joined #crystal-lang
<FromGitter> <> oprypin ( arch linux is not rock solid by essence
<FromGitter> <> yes it is 😠
<FromGitter> <> even though the error is not related here
<FromGitter> <> it is a rolling release distribution, things may breack
<FromGitter> <> anyway regarding the angry emoji - im joking ofc
<FromGitter> <> 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> <> you could add a CD with GitHub Actions
DTZUZU_ has quit [Ping timeout: 265 seconds]
<FromGitter> <> generate a new priv/pub SSH key, then a the private key as a secret
<FromGitter> <> the static binary will be deployed automatically. If you like, you could even keep the service restart manual if you want more safety
<FromGitter> <> yeaaa i don't trust that
<FromGitter> <> trust what?
<FromGitter> <> GitHub with my machine
<FromGitter> <> trust GitHub to deploy a trustworthy binary, or working one?
<FromGitter> <> trust arbitrary access
<FromGitter> <> you're afraid that it will send a "bad" binary?
<FromGitter> <> because of course, it will only have this right
<FromGitter> <> it can literally do anything on my machine
<FromGitter> <> well with enough hardening it can be reasonable
<FromGitter> <> the service already runs as nobody
<FromGitter> <> but i don't care to risk
<FromGitter> <> trusting docker hub building our image vs GitHub building our artifacts... close to the same
<FromGitter> <> well i don't trust docker hub so yes ... same
<FromGitter> <> ideally you could build on 2 services and compare their hash
<FromGitter> <> your service is not really security sensitive, being only available for already public repos?
<FromGitter> <> the point isn't my service but that the machine can be taken over
<FromGitter> <> also it does work with private repo's
<FromGitter> <> As I said, of course you'll give it a user with no permissions other than writing to a directory
<FromGitter> <> im not confident in my ability to set this up right
<FromGitter> <> fair enough, not that hard form what I've seen: only allow sftp acces to a dir
postmodern has joined #crystal-lang
_ht has quit [Read error: Connection reset by peer]
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<FromGitter> <> is this a bug or a feature?
<FromGitter> <> 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> <> 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> <> even if D is used, it still works:
<FromGitter> <> it means my method is actually defined for Union(B, C), not A
<FromGitter> <> like if the type inference system has priority over my type anontation
<straight-shoota> what exactly would you expect?
<FromGitter> <> I would expect the compiler to tell me that my case is missing `A` and `D` conditions
<FromGitter> <> 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> <> yeah but I don't want that
<FromGitter> <> maybe someone will use my lib and write another invocation
<FromGitter> <> 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
<FromGitter> <> Blacksmoke16: hmm indeed
<straight-shoota> you can cast to `A` explicitly using `a =`
<FromGitter> <> but then my case would only match `in A`, right?
<FromGitter> <> 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> <> 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> <> 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> <> 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> <> 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> <> hmm
<FromGitter> <asterite> Sealed types strike again!
<FromGitter> <> what am I getting wrong here?
<FromGitter> <Blacksmoke16> drop the `JSON.`
<FromGitter> <Blacksmoke16> and actually `include JSON::Serializable`
<straight-shoota> @asterite to be honest, I'm not sure sealed types would be practical or actually improve anything for this use case
<FromGitter> <> yeah that was a test, it still complains about "Error: undefined method 'use_json_discriminator' for A.class"
<FromGitter> <> aaargh
<FromGitter> <> thanks Blacksmoke16
<FromGitter> <> so the case behavior change here:
<FromGitter> <> 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> <> right
_ht has quit [Remote host closed the connection]
<FromGitter> <> I hope one day to have a restricted subset of Crystal which allows improved compile times
<oprypin> thats #nim
<FromGitter> <> I don't really think it is, on the syntax POV
<FromGitter> <> I find Crystal a bit easier to start with, because more procedural/less functional
<FromGitter> <asterite> I need to try nim again...
<FromGitter> <> 1) 8k issues on Nim O.o
<FromGitter> <> That's strange, perhaps they didn't clean them up
<FromGitter> <> The language sounds simpler overall
<FromGitter> <> j8r ( haha no its surface is like 5x bigger
<FromGitter> <> Ha? I looked at some code in the compiler
<FromGitter> <> At least, the most used constructs are quite narrow there
<FromGitter> <> A least, for proc, it is used in place of `def`, `Proc`, proc literal, and perhaps block, and maybe more
<FromGitter> <> 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> <> 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> <> 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> <asterite> Otherwise we would almost be as popular as
<FromGitter> <> oprypin ( so why you said nim if its surface is 5x bigger than Crystal? It can't be a subset 🤔
<FromGitter> <> it just has more features all over the place
<FromGitter> <> 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> <> Nim and Crystal are close, Ruby a lot more
<FromGitter> <HertzDevil>
<FromGitter> <asterite> To realize how far we've come with intuitiveness in programming languages I recommend writing a real world application in Haskell :-)
<FromGitter> <Blacksmoke16> ```import Program ⏎ ⏎ Program.code``` []
<FromGitter> <Blacksmoke16> :S
sagax has quit [Quit: Konversation terminated!]
<FromGitter> <alexherbo2> just learned with FileUtils about `extend self` in modules 🤯
<FromGitter> <alexherbo2> is there a shorthand to pass named arguments with the name of the variable, like in javascript?
<FromGitter> <asterite> Looking it that way it does seem very intuitive :-D
<FromGitter> <alexherbo2> `"mycomand", ["arg1"], input: input)`
<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> <> @HertzDevil: no it's a very good feature
<FromGitter> <> 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> <HertzDevil> ```code paste, see link``` []
<FromGitter> <HertzDevil> no need to be a language feature
<FromGitter> <> 😩
<FromGitter> <> @HertzDevil: how would u rewrite this line ⏎
<FromGitter> <HertzDevil> why
<FromGitter> <> so i dont freaking make a typo, thats why. because i did today, from all this copypasting
<FromGitter> <> `NightlyLink.gen_dash_by_branch(repo_owner: repo_owner, repo_name: repo_owner, workflow: workflow.rchop(".yml"), branch: branch)` ⏎ ⏎ oopsie woopsie
<FromGitter> <HertzDevil> except when that's also a legit use case and writing the short form produces a typo in the opposite direction
<FromGitter> <> crystal doesn't allow duplicate method args
<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> <> who says we have to do anything
<FromGitter> <> you said ⏎ ⏎ > that sounds like a counterfeature
<FromGitter> <> 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> <> 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> <> 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> <> @HertzDevil: the macro substitute is going to be quite hindered by
<FromGitter> <> can write `f(x, y = 1 + 2, z)` though *hiss*