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
<FromGitter> <djberg96> not as bad as a corrupted triple linked list, but still bad
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
issyl0 has quit [Write error: Connection reset by peer]
issyl0 has joined #crystal-lang
chachasmooth has quit [Ping timeout: 264 seconds]
chachasmooth has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 258 seconds]
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
chachasmooth has quit [Ping timeout: 258 seconds]
chachasmooth has joined #crystal-lang
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
f1reflyylmao is now known as f1refly
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 260 seconds]
<repo> jhass: hey! i'm trying out gobject to use libvips: https://libvips.github.io/libvips/API/current/binding.md.html
<repo> jhass: i installed the libvips package and wrote `require "gobject"` and `require_gobject "Vips"` but that fails: Typelib file for namespace 'Vips' (any version) not found (Exception)
<repo> what am i missing?
sz0 has quit [Ping timeout: 240 seconds]
r0bby has quit [Read error: Connection reset by peer]
sz0 has joined #crystal-lang
r0bby has joined #crystal-lang
hightower3 has joined #crystal-lang
<jhass> repo: well, doesn't look like libvips provides a .gir file
sz0 has quit [Read error: Connection reset by peer]
r0bby has quit [Read error: Connection reset by peer]
sz0 has joined #crystal-lang
r0bby has joined #crystal-lang
<repo> jhass: yeah i figured :/
issyl0 has quit [Read error: Connection reset by peer]
issyl0 has joined #crystal-lang
alexherbo2 has joined #crystal-lang
sorcus has quit [Quit: WeeChat 3.0]
sorcus has joined #crystal-lang
xaxisx has joined #crystal-lang
<FromGitter> <alexherbo2> hello
<FromGitter> <alexherbo2> what is the Crystal equivalent of
<FromGitter> <alexherbo2> ```head, *tail = argv```
<FromGitter> <HertzDevil> there isn't
<FromGitter> <alexherbo2> :(
<FromGitter> <alexherbo2> what is the crystal way?
<FromGitter> <HertzDevil> head = argv[0] ⏎ tail = argv[1..]
<FromGitter> <erdnaxeli:cervoi.se> `head = argv.shift` ?
<FromGitter> <alexherbo2> ```head = argv[0] ⏎ tail = argv[1..-1]``` [https://gitter.im/crystal-lang/crystal?at=6022bbd99238c531ad34f8f8]
<FromGitter> <alexherbo2> yeah
<FromGitter> <alexherbo2> shift will modify the argv
<FromGitter> <erdnaxeli:cervoi.se> yes
<FromGitter> <asterite> `head, tail = argv[0], argv[1..]`
<FromGitter> <HertzDevil> iirc the reason is we want `Tuple#[](Range)` to also return a tuple but we also want it to return an array
<FromGitter> <HertzDevil> if `argv` is a tuple there is a different way actually
<FromGitter> <HertzDevil> ```def extract(car, *cdr) ⏎ {car, adr} ⏎ end ⏎ ⏎ extract(*argv)``` [https://gitter.im/crystal-lang/crystal?at=6022bc7a428d9727dd6679a9]
<FromGitter> <asterite> I think `head, *tail = exp` should just expand do `tmp = exp; head = exp[0]; tail = exp[1..]` and then we need to add the compiler logic so that you can index tuples with ranges at compile-time
<FromGitter> <asterite> I wouldn't mind that at all. And then it would also work for arrays and other types too
<FromGitter> <asterite> I also proposed splats in array (or array-like) types in the past but it was rejected: https://github.com/crystal-lang/crystal/issues/462
<FromGitter> <HertzDevil> adr -> cdr but you get the idea
<FromGitter> <HertzDevil> no that's crystal-lang/crystal#132
<FromGitter> <HertzDevil> splat expansion inside the rhs is a different thing
<FromGitter> <HertzDevil> (the corresponding issue for tuples being crystal-lang/crystal#3718)
<FromGitter> <HertzDevil> well my concern is, something like this would happen
<FromGitter> <HertzDevil> ```tup = {3, 5, 7, 9} ⏎ x = 2 ⏎ tup[1..2] # => {5, 7} ⏎ tup[1..x] # => [5, 7]``` [https://gitter.im/crystal-lang/crystal?at=6022bdff32e01b4f7185ced4]
<FromGitter> <HertzDevil> we should avoid that, but the transformation is purely syntactic atm so it doesn't know whether `tup` is a tuple
<FromGitter> <HertzDevil> or maybe it's okay anyway since the range cannot be a "conditionally" constant expression...?
<FromGitter> <HertzDevil> the difference to single-element `#[]` is that one always returns something that's `<= Union(*T)` whether or not the indexer is a constant expression
HumanG33k has quit [Quit: Leaving]
<FromGitter> <HertzDevil> here if you write out the full return type it becomes `Array(Union(*T))` and the union of O(n^2) tuple types
<FromGitter> <HertzDevil> what if we rewrite constant range indexers to a distinct type 🤔
<FromGitter> <asterite> Sorry, I don't understand what's the issue
HumanG33k has joined #crystal-lang
<FromGitter> <asterite> if it's a range composed of integer literals, and that's passed to a tuple, then that's analyzed at compile time
<FromGitter> <HertzDevil> so it's okay for `Tuple#[](Range)` to return an array or tuple depending on whether that range is a constant expression?
<FromGitter> <HertzDevil> and even if it's okay for `Tuple` alone it might break things if `Indexable` gets the same overload in the future
<FromGitter> <asterite> Yes, it's okay, at least in my mind
<FromGitter> <asterite> if you have a tuple and index it with an integer literal, you get the type in that position
<FromGitter> <asterite> if you do `x = 1` and index it by `x` you get the union of all types in the tuple
<FromGitter> <asterite> possibly also raising if it's out of bounds
<FromGitter> <asterite> other languages, like rust, have x.1, x.2, etc., to access a tuple to avoid this "confusion"
<FromGitter> <asterite> I prefer a uniform and simpler syntax, or a smarter language
<FromGitter> <asterite> Though as a beginning we could just have it work at compile-time for tuples, and if it's not a literal then error as usual
HumanG33k has quit [Read error: Connection reset by peer]
<FromGitter> <asterite> In case you are curious, this is where the hardcoded logic for that lives: https://github.com/crystal-lang/crystal/blob/f0901e1c825de1095d77998ffe8890bfca66def0/src/compiler/crystal/semantic/call.cr#L263 (there's also a bit on the codegen part)
<FromGitter> <HertzDevil> yeah i know the whole TupleIndexer stuff
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): i had promised a way to keep GitHub scheduled workflows working. here: https://github.com/oprypin/reenable-gha
<FromGitter> <jrei:matrix.org> oprypin (https://matrix.to/#/@oprypin:matrix.org): Nice!
<FromGitter> <jrei:matrix.org> I have an idea: I fork the project, then add a CI to schedule the script :)
<oprypin> that ... is an amazing idea
<FromGitter> <jrei:matrix.org> Of course the token will be a secret of the project.
<FromGitter> <asterite> @HertzDevil Hehe, sorry. I guess by now you know the entire compiler :-D
<FromGitter> <jrei:matrix.org> oprypin: do you mind I create a PR about adding the CI, so the procedure would be to fork the project and add a token to it?
<FromGitter> <oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): if you want you're welcome to. i can also do it myself quite quickly. let me know your preference
<FromGitter> <jrei:matrix.org> If you can do it, you'll certainly do it faster & better than me 😅
<FromGitter> <oprypin:matrix.org> j8r (https://matrix.to/#/@jrei:matrix.org): done. thanks
<FromGitter> <djberg96> is there an equivalent of `File.which` in Crystal somewhere?
<oprypin> djberg96, Process.find_executable
<FromGitter> <djberg96> excellent, thank you
xaxisx has quit [Quit: Leaving...]
straight-shoota has quit [Remote host closed the connection]
straight-shoota has joined #crystal-lang
<FromGitter> <jrei:matrix.org> oprypin (https://matrix.to/#/@oprypin:matrix.org): awesome! Going to test it
<FromGitter> <jrei:matrix.org> You were fast :o
alexherbo2 has quit [Remote host closed the connection]
_ht has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
<raz> hmm python is adding pattern matching
<raz> shouldn't they at least finish their v3 transition first...
<FromGitter> <oprypin:matrix.org> oh geez
<FromGitter> <HertzDevil> > During failed pattern matches, some sub-patterns may succeed. For example, while matching the value `[0, 1, 2]` with the pattern `(0, x, 1)`, the sub-pattern `x` may succeed if the list elements are matched from left to right. The implementation may choose to either make persistent bindings for those partial matches or not.
<FromGitter> <HertzDevil> big oof
<FromGitter> <asterite> Where is that from?
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <HertzDevil> it looks very python at least
<FromGitter> <HertzDevil> the c++ pattern matching ts looks ugly
<FromGitter> <HertzDevil> looked at java too and it only has a "limited form" that works with `instanceof`: https://openjdk.java.net/jeps/394
<FromGitter> <HertzDevil> and it's something crystal does all the time (`is_a?` constrains a variable's type, even within a conditional)
<FromGitter> <asterite> Yeah... I think Crystal was the first one to do this, and I think no other compiled languages "changes" the type of a variable (you have to use a different one)
<FromGitter> <asterite> Well, sorbet does it too, for Ruby