ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
<watzon> Does anyone know of something like IO::ByteFormat for Ruby? All I've managed to find is bitpack, but it hasn't been touched in 11 years.
<watzon> All of the gems that deal with binary seem to be more declarative
sz0 has quit [Quit: Connection closed for inactivity]
hendursaga has joined #crystal-lang
<hendursaga> Hello all! I finally got around to checking Crystal out, and so far it looks good! I loved Ruby's syntax and idioms, but didn't like its speed, or lack thereof.
<FromGitter> <Blacksmoke16> good to hear!
<hendursaga> The biggest thing that worries me is the lack of parallelism - but I suppose that might be added on sometime down the road?
<hendursaga> Hmmm. Do you still need to opt-in?
<FromGitter> <Blacksmoke16> yes
<hendursaga> State of REPL? I suppose it'd be hard like in Rust..
<FromGitter> <Blacksmoke16> there are some projects like But IMO it's just as easy to have a `` file that you can mess with
<FromGitter> <Blacksmoke16> or even setup `nodemon` to watch it and recompile automatically
aquijoule__ has joined #crystal-lang
aquijoule_ has quit [Ping timeout: 265 seconds]
chachasmooth has quit [Ping timeout: 264 seconds]
chachasmooth has joined #crystal-lang
hendursaga has quit [Remote host closed the connection]
hendursaga has joined #crystal-lang
sz0 has joined #crystal-lang
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
postmodern has joined #crystal-lang
teardown has quit [Remote host closed the connection]
teardown has joined #crystal-lang
aquijoule__ has quit [Ping timeout: 240 seconds]
hendursa1 has joined #crystal-lang
hendursaga has quit [Ping timeout: 268 seconds]
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
<FromGitter> <HertzDevil> so i got general pattern matching almost working with macros (good enough to define the matching semantics)
<FromGitter> <HertzDevil> time to write a full spec
<FromGitter> <alexherbo2> how create a named tuple from an array of values?
postmodern has quit [Quit: Leaving]
<FromGitter> <asterite> @HertzDevil Wow, nice! What does "general pattern matching" mean in Crystal?
<FromGitter> <HertzDevil> i want something similar to ruby 3's (single-statement) `=>` or `in` operator and i'm sure some others want it too
<FromGitter> <HertzDevil> if we have it, we could also extend case expressions in terms of such an operator
<FromGitter> <HertzDevil> (ruby had it backwards and defined the single-statement `in` in terms of a case expression)
<FromGitter> <HertzDevil> will be gathering some initial thoughts on the forum before making an issue
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
<FromGitter> <mohsinhijazee> Hello community. Is it possible to dynamically load a file and evaluate it? Like crystal eval but from within the program (somewhere there there's no crystal installation)?
deavmi has joined #crystal-lang
<straight-shoota> You can compile the compiler into your program use it to build the eval file and execute that program
<straight-shoota> at runtime
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
<FromGitter> <asterite> @HertzDevil is the pattern matching you are doing type safe?
<FromGitter> <HertzDevil> ```code paste, see link``` []
<FromGitter> <HertzDevil> it is
<FromGitter> <HertzDevil> the whole thing expands to a nested if expression like
<FromGitter> <HertzDevil> ```code paste, see link``` []
<FromGitter> <asterite> Nice!
<FromGitter> <asterite> So it's runtime pattern matching... I guess it's what we have right now too
<FromGitter> <asterite> Pattern matching is an overloaded term :/
HumanG33k has quit [Quit: Leaving]
HumanG33k has joined #crystal-lang
<FromGitter> <> @alexherbo2: you can use the regular namedtuple literal
<FromGitter> <> Like `{a: ary[0], b: ary[1]}`
<FromGitter> <alexherbo2> :(
<FromGitter> <> The keys must be known at compile-time
<FromGitter> <alexherbo2> I would hope we could pull the named tuple from an array
<FromGitter> <Blacksmoke16> would be possible if you first make the array into a hash, maybe with `.zip`
<FromGitter> <Blacksmoke16> then can use
<FromGitter> <alexherbo2> also, it's not ideal when using an array of named tuple, we cannot `.from` on the container
<FromGitter> <Blacksmoke16> but the better solution is to not use named tuples like this
<FromGitter> <Blacksmoke16> just use an array of structs or something
<FromGitter> <alexherbo2> `data = [] of { session: String, client: String, buffer_name: String, working_directory: String }`
<FromGitter> <Blacksmoke16> gross
<FromGitter> <Blacksmoke16> `data = [] of SomeType`
<FromGitter> <Blacksmoke16> `record SomeType, session: String, client: String, buffer_name: String, working_directory: String`
<FromGitter> <> Yeah
<FromGitter> <> Use structs, then you can add macro helpers inside
<FromGitter> <alexherbo2> you would declare a custom type even if it is just used for in the cli for a display?
<FromGitter> <Blacksmoke16> probably
<FromGitter> <> Can you provide an example in
<FromGitter> <> We will see whag fits the best ;)
<FromGitter> <Blacksmoke16> yea id just use a record
<FromGitter> <Blacksmoke16> can even do like `private record ...` if you dont want to expose it
<FromGitter> <alexherbo2> I noticed a bug in the option parser, for named command
<FromGitter> <alexherbo2> I have a `kcr shell` command, handling the `shell` command. when I run `kcr fzf shell`, it is recognized as `kcr shell`
<FromGitter> <alexherbo2> it should not recognize `shell`, because there is `fzf` before
teardown has quit [Ping timeout: 268 seconds]
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
DTZUZU__ has joined #crystal-lang
DTZUZU_ has quit [Ping timeout: 256 seconds]
<FromGitter> <> perhaps you better off using a library
<FromGitter> <> OptionParser is nice for littles CLIs, less for bigger ones
<FromGitter> <> yes
<FromGitter> <> if you like NamedTuples and descriptive over imperative, you may like
DTZUZU__ is now known as DTZUZU
<FromGitter> <kingsleyh> does anyone know if adding uniq to an array is likely to cause performance issues? I added one to an array and it gets hit 1000's of times per second but now the CPU is double what it was and that seems to be one of the only things I changed that sticks out to me
<FromGitter> <Blacksmoke16> i mean it would need to create a new array and iterate it fully so prob would have an impact, also depending on the size of the array
<FromGitter> <> uniq or uniq!?
<FromGitter> <> also consider using a Set
<FromGitter> <kingsleyh> uniq
<FromGitter> <kingsleyh> I think a Set is a fantastic idea!!!
<FromGitter> <> @kingsleyh: j8r ( uniq uses a set already.
<FromGitter> <kingsleyh> could my CPU go up by adding uniq to an array?
<FromGitter> <kingsleyh> or is that unlikely and it must be something else?
<FromGitter> <> That's good then using Set
<FromGitter> <> sure
<FromGitter> <> it could go up
<FromGitter> <kingsleyh> I'm re-implementing it and will benchmark it
<FromGitter> <> a Set is created anyway, better using one first
<FromGitter> <> it is a good change, even if this is not the cause,
chachasmooth_ has joined #crystal-lang
chachasmooth has quit [Ping timeout: 260 seconds]
<FromGitter> <asterite> @kingsleyh how big is the array you are calling `uniq` on?
<FromGitter> <asterite> I ask because if it's a small array (less than 17 elements) it deletes things in place, otherwise it needs to create a Hash with all the values and then get the uniq keys, which can be pretty expensive
maxpowa has quit [Ping timeout: 260 seconds]
maxpowa has joined #crystal-lang
<FromGitter> <> @asterite: I was not able to reproduce
<FromGitter> <> I did the the checkout, make clean, and `echo >`
<FromGitter> <asterite> what LLVM version?
<FromGitter> <> LLVM 11.0.1
<FromGitter> <> on Linux
<FromGitter> <asterite> well, i'm on mac, maybe that's why
<FromGitter> <> wait, I may need to compile the compiler (make clean), then compile the compiler with it
<FromGitter> <> I would like to bisect, but it is going to take a lot of time :/
<FromGitter> <> j8r ( so what did u reproduce here lol
teardown has joined #crystal-lang
<FromGitter> <> oprypin ( I reproduced with the issue's code
<FromGitter> <> not an empty program. I think going to compile the compiler will do it, I'm doing it
<FromGitter> <> Indeed, it was this - just reproduced
<FromGitter> <> j8r ( so let's make an automatic repro and run it
<FromGitter> <> please put what you have
<FromGitter> <> of course I'm writing a comment right now
<FromGitter> <> that's why I'm doing it :)
<FromGitter> <> how can I force the `make` command instead of having `make: Nothing to be done for 'crystal'.`
<FromGitter> <> for now I'm just touching a random file in `src/`
<FromGitter> <> got it `-B`
richbridger has joined #crystal-lang
<FromGitter> <> ok cya later
<FromGitter> <Blacksmoke16> cant you just run `make clean` first?
<FromGitter> <> aha nice comment
<FromGitter> <> time for a one day bisect :/
<FromGitter> <> j8r ( what exactly happens when u run `bin/crystal run --release`
teardown has quit [Ping timeout: 268 seconds]
<FromGitter> <> a sigfault
<FromGitter> <> @Blacksmoke16: apparently not, because that deletes the compiler we're trying to use :D
<FromGitter> <Blacksmoke16> oof, fair point ha
<FromGitter> <> I'll start with Crystal 0.35.1
<FromGitter> <> hopefully `` is still there for quick & easy 0.35.1 install :D
<FromGitter> <Blacksmoke16> could prob just grab it from the GH release
<FromGitter> <> sure, but slower
<FromGitter> <> I'll use docker if it was not available
<FromGitter> <> but I want max perf because it is going to be very very long
teardown has joined #crystal-lang
<FromGitter> <> oprypin ( you started a bisect too, we'll see which one is the fastest haha
<FromGitter> <> You'll probably be faster than me, I have a Ryzen 5 1600 AF. Even putting the governor to performance does not change much
<FromGitter> <> it is still good to do it both, I do with LLVM 11 and you 10
<FromGitter> <> j8r ( wait i thought crystal 0.35.1 doesnt support llvm 11
<FromGitter> <> thats why i got llvm 10 seeing the error
<FromGitter> <> ...oops yes
<FromGitter> <> true, true
<FromGitter> <> doing it back with `export LLVM_CONFIG=/usr/bin/llvm-config-10`
<FromGitter> <kingsleyh> if there are 2 shards with the same name - and the same require "shard" - is it possible to use them both at the same time?
<FromGitter> <kingsleyh> can you alias one of the requires ?
<FromGitter> <Blacksmoke16> possibly, assuming none of the methods/type names conflict
<FromGitter> <Blacksmoke16> no
<FromGitter> <kingsleyh> well the require is the same so that is a problem lol
<FromGitter> <> no point of having the same name
<FromGitter> <> define different ones in shard.yml
<FromGitter> <kingsleyh> yeah just two of the shards have the same name
<FromGitter> <kingsleyh> how do you require them tho?
<FromGitter> <Blacksmoke16> id vote try and get one of them to change their name
<FromGitter> <kingsleyh> well this one was added 3 months ago:
<FromGitter> <kingsleyh> adnd this one was 3 years ago:
<FromGitter> <Blacksmoke16> cant just use one?
<FromGitter> <> probably dependency tree
<FromGitter> <kingsleyh> I want to try the new one and I already have the old one - and don't want to rip out all the old one at once
<FromGitter> <kingsleyh> there is only 1 file - I might just copy paste it for now
<FromGitter> <kingsleyh> but it would be cool to have a way to handle this situation
<FromGitter> <kingsleyh> like with an alias or other such thing
<FromGitter> <> here you can't
<FromGitter> <> they use the same object
<FromGitter> <> you'd have to sed into the files to rename it
<FromGitter> <kingsleyh> I just copy and paste for now and change some names
<FromGitter> <kingsleyh> they are both just 1 file each
<FromGitter> <kingsleyh> and decide which I like better
<FromGitter> <> @kingsleyh: make a writeup about it, im very curious
<FromGitter> <kingsleyh> Ok
<FromGitter> <> j8r ( lol i'm bisecting *something* but in fact i'm not getting the crash xD
<FromGitter> <> how is your success?
beefstar has joined #crystal-lang
beefstar has left #crystal-lang [#crystal-lang]
<FromGitter> <> I definitely got segfaults
<FromGitter> <> good good
<FromGitter> <> my bisect finished but it got no results :D
<FromGitter> <> it is finishing, my system slept 😅
<FromGitter> <> I don't know why you didn't have a result, I'm on LLVM 10.0.1 too
<FromGitter> <> is your crystal 0.35.1 statically linked?
<FromGitter> <> no'
<FromGitter> <> mine yes
<FromGitter> <> `ldd` said it is, but `file` not
<FromGitter> <> it may have nothing to do, but that's one difference.
<FromGitter> <> finally, got a result
<FromGitter> <> it's a bit of a weird result o.o
<straight-shoota> indeed
<straight-shoota> only semantic change is implementation of offsetof
<straight-shoota> and offsetof isn't even used in the compiler or stdlib
<FromGitter> <> I'll run again, I think I messed up a bit
<FromGitter> <> in my script I didn't have sh -e on first steps
<straight-shoota> but you can at least reduce the search range
<straight-shoota> for completeness, which exact LLVM version are you using?
<FromGitter> <> LLVM 10.0.1
<straight-shoota> kay, so sayme as oprypin
<straight-shoota> *same
_ht has quit [Remote host closed the connection]
<FromGitter> <> how crystal tool expand is supposed to work?
<FromGitter> <> "crystal tool expand -c src/some/❌y src/" tells me there is nothing to expand
<FromGitter> <> well I have an error in my macro it seems, to the compiler printed it for me ^^
<FromGitter> <> nobody knows how to use it
<FromGitter> <> :(
<FromGitter> <Blacksmoke16> just add `{{debug}}` in you macro somewhere
<FromGitter> <> ah I always forgot about that, thanks
<FromGitter> <> oprypin ( now I have ".. was both good and bad"
<FromGitter> <> I don't understand a thing...
<FromGitter> <> o.o
<FromGitter> <> can u just run through my command
<FromGitter> <> after `git bisect reset` of course
<FromGitter> <> mine is similar, but ok
<FromGitter> <> now I try to reproduce (again) on 0.36.1
<FromGitter> <> I've a script. I'll try on LLVM 10, then LLVM 11
<FromGitter> <> calling a type "Union" is not a good idea :D
<FromGitter> <> haha, you have to use `::Union` then
<straight-shoota> "both good and bad" *could* mean it doesn't fail always. Which would be really bad.
<straight-shoota> But most failing cases consistently reproduce, so it's unlikely
<straight-shoota> > haha, you have to use `::Union` then
<FromGitter> <> like any already existing top-level object
<FromGitter> <> (Array, Hash, etc)
<FromGitter> <> ok, so got the crash with my posted commands using LLVM 11 - normal.
<FromGitter> <> Except that Union are used almost everywhere when you do "Something?"
<FromGitter> <> so you can very strange errors like this:
<FromGitter> <> anyway, I figured it out quickly
<FromGitter> <> and it was just a bad name in a spec file
<FromGitter> <> I was talking about placing it in a namespace
<FromGitter> <> not overwriting the top-level definition
<FromGitter> <> to be clear, like this: `struct Foo::Union; end`
<FromGitter> <> yes
<FromGitter> <> oprypin ( straight-shoota: I tried with LLVM 10 - cannot reproduce
<FromGitter> <> try llvm 11 with my script
<FromGitter> <> LLVM 11 make it crash indeed
<FromGitter> <> the issue is 0.35.1 supports only LLVM 10
<FromGitter> <> ok but like try with my script
<FromGitter> <> ok ok
<FromGitter> <Blacksmoke16> Could you checkout the 0.35.1 tag, apply the llvm 11 patch, build, then use the resulting binary
<FromGitter> <> it skips versions that dont support llvm, worst case you'll bisect up to that llvm version
<FromGitter> <> your script, or your command?
<FromGitter> <> @Blacksmoke16: I thought of doing that, maybe that's "just" LLVM 11 not being fully supported
<FromGitter> <> oprypin ( I'm running
<straight-shoota> you could cherry pick #9829 on top of 0.35.1
hendursa1 has quit [Remote host closed the connection]
hendursa1 has joined #crystal-lang
<FromGitter> <> got issues with the cherry pick
<FromGitter> <> I'll try to figure out the conflicts.
<FromGitter> <> I can integrate a commit just after 0.35.1?