ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
<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 -]
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:
<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> <> `head = argv.shift` ?
<FromGitter> <alexherbo2> ```head = argv[0] ⏎ tail = argv[1..-1]``` []
<FromGitter> <alexherbo2> yeah
<FromGitter> <alexherbo2> shift will modify the argv
<FromGitter> <> 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)``` []
<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:
<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]``` []
<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: (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> <> j8r ( i had promised a way to keep GitHub scheduled workflows working. here:
<FromGitter> <> oprypin ( Nice!
<FromGitter> <> I have an idea: I fork the project, then add a CI to schedule the script :)
<oprypin> that ... is an amazing idea
<FromGitter> <> 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> <> 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> <> j8r ( if you want you're welcome to. i can also do it myself quite quickly. let me know your preference
<FromGitter> <> If you can do it, you'll certainly do it faster & better than me 😅
<FromGitter> <> j8r ( 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> <> oprypin ( awesome! Going to test it
<FromGitter> <> 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> <> 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 -]
<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`:
<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