ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
ur5us_ has joined #crystal-lang
<FromGitter> <Dan-Do> @SamantazFox do you see slowness in stdlib json?
<FromGitter> <Dan-Do> In Kostya's json benchmark, it's 10 times slower then simdjson
<SamantazFox> Dan-Do: yes, from time to time
<SamantazFox> it sometimes uses a lot of CPU and/or RAM
<SamantazFox> but that improved greatly since we improved the code and make preliminary checks before digging too far into the hierarchy
<FromGitter> <Dan-Do> 👍
ox has joined #crystal-lang
ox is now known as oz
ur5us_ has quit [Ping timeout: 264 seconds]
ur5us_ has joined #crystal-lang
adam129 has joined #crystal-lang
cfebs has quit [Ping timeout: 250 seconds]
cfebs has joined #crystal-lang
adam12 has quit [Ping timeout: 250 seconds]
adam129 is now known as adam12
ur5us has joined #crystal-lang
ur5us_ has quit [Read error: Connection reset by peer]
ur5us_ has joined #crystal-lang
ur5us has quit [Ping timeout: 264 seconds]
ur5us_ has quit [Ping timeout: 268 seconds]
notzmv has quit [Ping timeout: 245 seconds]
notzmv has joined #crystal-lang
dmgk has left #crystal-lang [#crystal-lang]
taskylizard has joined #crystal-lang
taskylizard has quit [Changing host]
taskylizard has joined #crystal-lang
taskylizard has quit [Read error: Connection reset by peer]
taskylizard has joined #crystal-lang
taskylizard has quit [Quit: Leaving]
<FromGitter> <naqvis> doesn't *variadic* means *zero* or more params?
<FromGitter> <naqvis> https://carc.in/#/r/cbyy
<FromGitter> <naqvis> am i missing something?
<SamantazFox> naqvis: you're missing a default value for your function arguments, so you can't pass 0 args.
<SamantazFox> Oh, and splat parameters can't have default values
<SamantazFox> So you're forced to pass at least one arg
<FromGitter> <naqvis> yeah, and that was my question on how to understand variadic params
<FromGitter> <naqvis> per defintion that means zero or more
<SamantazFox> it's splat parameters, it's a little bit different from variadic parameters
<FromGitter> <naqvis> Splat is variadic argument in Crystal.
<SamantazFox> This is in macros, this is a bit different
<SamantazFox> I've made an issue about that: the macro language, while being very close to the rest of the crystal code, has small differences.
<SamantazFox> here is for instance a macro with a splat parameter, and you'll see that it accepts 0+ arguments
<SamantazFox> Here's is the issue: https://github.com/crystal-lang/crystal/issues/11143
<SamantazFox> s/Here's is/Here is/
<FromGitter> <naqvis> variadic params are turned to `TupleLiteral` in macro land and that's same as for non-macro world.
<FromGitter> <naqvis> this seems to be bug to me
hightower2 has quit [Ping timeout: 264 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <asterite> why?
<FromGitter> <asterite> Strange, I thought this was documented. When a splat has a type restriction, it only matches one or more args. The reason is that if you have multiple overloads with different types, for example `foo(*x : Int32)` and `foo(*x : String)`, which one is chosen if you call it without args? The answer is: none! You have to define a separate overload `foo` without args. No ambiguity! But if there's no type
<FromGitter> ... restriction, the problem doesn't exist, so it matches zero args. Given that macros don't have type restrictions, splat match zero args.
<FromGitter> <naqvis> thanks for the clarification Ary. But this restriction means that one can't have `Proc` defined for variadic params
<FromGitter> <naqvis> as `Proc` requires type definitions to be defined
cfebs_ has joined #crystal-lang
<SamantazFox> <asterite> "Strange, I thought this was documented." <- I'm going to be honnest: many, many edge cases and other complex part of the Crystal language are not documented at all.
<SamantazFox> Like, sometimes, I have to go in the stdlib code to understand how some specifics work
<FromGitter> <Blacksmoke16> it would be helpful if people create issues or ideally PRs when they run into this stuff
<FromGitter> <Blacksmoke16> either on the book repo or crystal itself if its an API thing
<SamantazFox> I do!
<FromGitter> <Blacksmoke16> ❤️
cfebs has quit [*.net *.split]
oz has quit [*.net *.split]
HumanG33k has quit [*.net *.split]
pusewic|away_ has quit [*.net *.split]
lanodan has quit [*.net *.split]
cfebs_ is now known as cfebs
oz has joined #crystal-lang
lanodan has joined #crystal-lang
HumanG33k has joined #crystal-lang
pusewic|away_ has joined #crystal-lang
<SamantazFox> reminds me that I forgot to open an issue for something
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #crystal-lang
ur5us_ has joined #crystal-lang
<riza> puts [1,1,1].reduce(&.+) => 1
<riza> I expected 3...but I don't know why that didn't work
<riza> puts [1,1,1].reduce { |acc, i| acc + i } => 3
<straight-shoota> `&.+` has no arguments, so it references the unary operator
<straight-shoota> it's essentially `[1, 1, 1].reduce { |acc, i| +i }`
<riza> oh yes, right. the "positive" sign strikes again
<riza> ruby has that figured out somehow
<straight-shoota> Ruby has no overloading so there's only one + method
<riza> I don't follow what you mean, how is overloading at play here?
<straight-shoota> wait
<straight-shoota> Short block syntax in Ruby are just symbols which are turned into a proc and call a method of their own name, forwarding all block parameters.
<straight-shoota> In Crystal it's a separate syntax feature and you write the call explicitly with full controll over it
<riza> there we go, that's what I was assuming
ua__ has quit [Ping timeout: 268 seconds]
<FromGitter> <Blacksmoke16> fwiw in this case you can just use `#sum`
<riza> well... why didn't you say that 45min ago! hah
<FromGitter> <jrei:matrix.org> Not fun otherwise :)
<riza> does the crystal implementation of Time provide for a notion of time which isn't fixed to a day? or is the practice to simply ignore the date-part of a Time if all that's needed is the hours/minutes/esconds
<FromGitter> <Blacksmoke16> Time::Span maybe?
<FromGitter> <oprypin:matrix.org> nah that's not it. ⏎ i think there isn't such a thing in crystal
<FromGitter> <Blacksmoke16> It's more so for duration yea
<FromGitter> <oprypin:matrix.org> i've actually never run into such a thing anywhere, so i was surprised that Python has it
ua_ has joined #crystal-lang
<SamantazFox> Time::Span seems the more appropriate to simply store hours/minutes/seconds
<SamantazFox> And if required, can easily be applied to a Time object.
<FromGitter> <Blacksmoke16> yea it stores a duration of time
<FromGitter> <Blacksmoke16> what's your use case for only needing the time and not the date?
rymiel_ has joined #crystal-lang
rymiel_ has quit [Client Quit]
ur5us_ has quit [Ping timeout: 256 seconds]