ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<oprypin> actions can get the token completely implicitly btw
deavmi has quit [Read error: Connection reset by peer]
<oprypin> also retroactively change to grab a token if before they weren't
<FromGitter> <Blacksmoke16> hm?
deavmi has joined #crystal-lang
<oprypin> Blacksmoke16, this retroactively changes an action to require and implicitly grab a personal token https://github.com/oprypin/find-latest-tag/commit/78f50b76101d8bf1f1f2d154e65053b5acf10952
<FromGitter> <Blacksmoke16> hm
<FromGitter> <Blacksmoke16> for use within the action i imagine tho?
<oprypin> Blacksmoke16, well yes, but the action could be doing anything at all with it. publishing or overwriting your repos
<oprypin> i *think*, not entirely sure how it works
<FromGitter> <Blacksmoke16> the built in token doesnt have permission for that
<oprypin> oh hm ok
<oprypin> sorry & thanks for clarifying
<oprypin> well anyway me and @j8r came to the same solution without an action or token
<FromGitter> <Blacksmoke16> not one way to solve a problem
zorp has joined #crystal-lang
zorp has quit [Ping timeout: 256 seconds]
Vexatoast has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
hightower2 has quit [Ping timeout: 265 seconds]
<FromGitter> <UnsolvedCypher_gitlab> I'm getting an `invalid cross-device link` error when attempting to use File.rename. Is there a method that supports moving files regardless of location? FileUtils.mv is an alias of this method and has the same result
<FromGitter> <Blacksmoke16> Uhh
<FromGitter> <Blacksmoke16> What os, version etc?
<FromGitter> <UnsolvedCypher_gitlab> I'm on Linux (ArchLinux specifically but I'm not sure if that matters)
<FromGitter> <Blacksmoke16> workaround, try doing a copy/delete
<FromGitter> <UnsolvedCypher_gitlab> Kernel is 5.6.11-arch1-1, Crystal is 0.34.0
<FromGitter> <UnsolvedCypher_gitlab> Yes, copy/delete does work so I'll do that in the meantime :)
<FromGitter> <UnsolvedCypher_gitlab> If this is not intended behavior, I can open an issue
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/7777 prob related
<FromGitter> <UnsolvedCypher_gitlab> Hmm that seems to imply that this wasn't happening before
<FromGitter> <Blacksmoke16> dunno
rocx has quit [Ping timeout: 260 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <spTorin> How turn on autoformat in VSCode with extension `faustinoaq.crystal-lang`?
<raz> you mean "format as you type"? hmm
<raz> (not sure about that, i always just hit alt+shift+f)
_ht has joined #crystal-lang
<FromGitter> <spTorin> Just want run `crystal tool format` on key or on-save.
<oprypin> @spTorin: it should work, but does formatting work at all?
<FromGitter> <bew> @UnsolvedCypher_gitlab this is how linux's `mv` does it as well, there is no other way when the files goes from one drive to the other. Maybe the stdlib's function could hide this, but I'd say it's also important to know what's really going on when you try to do this!
alexherbo2 has quit [Ping timeout: 256 seconds]
<FromGitter> <spTorin> @oprypin `crystal tool format file.cr` worked well. But I can't find how use it in VSCode.
<oprypin> spTorin, well there's mandatory configuration in the extension to set the path to crystal executable
<oprypin> which system is this anyway
alexherbo2 has joined #crystal-lang
zorp has joined #crystal-lang
<FromGitter> <j8r> oprypin: useful, thanks. TIL git worktree
<FromGitter> <j8r> Why do you want to keep the history of a gh-pages branch?
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#60bdcf0 (master - Resolve the always-present Windows linker's warnings (#9307)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/687752817
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9307 (Resolve the always-present Windows linker's warnings)
<oprypin> j8r, you know, i also wonder about why i want to keep the history of 1MB search-index.json files
<oprypin> the real answer is that keeping the history is the default option we should be striving for
<FromGitter> <j8r> documentation is automatically generated
<FromGitter> <j8r> I don't say it is not useful to keep the documentation history, but only if we can still access to it (like for the crystal compiler)
<raz> hey java is stealing from crystal now! https://cr.openjdk.java.net/~rpressler/loom/loom/sol1_part1.html
<raz> i'm not even mad tho
<oprypin> what are you talking abou
<raz> fibers
<oprypin> thats Crystal stealing from Go
<oprypin> (for no good reason but w/e)
<raz> i wonder who had them first, hmm
<oprypin> >> Process.run("foo")
<DeBot> oprypin: from ??? - https://carc.in/#/r/92yd
<oprypin> i wonder why crystal doesnt show *what* process it is that doesn't exist
<oprypin> it's especially obscure at compile time
<oprypin> >> {{`foo`}}
<DeBot> oprypin: Error: error executing command: foo, got exit status 127 - https://carc.in/#/r/92ye
<oprypin> wait that one is good :)
<oprypin> ah but it's coming from the shell!
<raz> woopsie
<oprypin> unfortunately on Windows there's no happy accident with the shell, and that one was really annoying to work with. something doesnt work randomly and all you get is `Error executing process: No such file or directory`
rocx has joined #crystal-lang
<raz> hm, well who runs carc.in? they might wanna know ;)
<oprypin> raz, know what? there's no problem here. it's jhass running it, anyway
<raz> ah ok, i though arbitrary exec wasn't supposed to be allowed
<raz> n/m, it also works without your wrapper. i had thought that was the whole point of the pastie lol
<oprypin> raz, the wrapper is IRC-bot-specific, i didnt do it
<raz> ahh ok
<oprypin> all it does is add `p!` to the last expression
<raz> well i think the crystal exception basically wraps the errno label (see `errno -l`)
<raz> it could also include the arguments that were tried to be more helpful, but not sure if that could raise potential security/privacy issues (stuff leaking into logs etc.)
<oprypin> 🤔
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo2 has joined #crystal-lang
<yxhuvud> raz: I note that loom is implementing at least some of their async using io_uring (on linux). That is pretty nity.
<yxhuvud> *nifty
<raz> yep, i wasn't entirely serious with that above remark of course. ;) it looks pretty cool and is prob a bit more advanced than what crystal does atm. (just wanted to applaud that crystal is def on a good track with its concurrency model :+1:)
<FromGitter> <UnsolvedCypher_gitlab> @bew I understand that that is how it works under the hood, but I still think it would be helpful to have a function to do this since most high-level programs probably don't care where the files are located and just want to get it from one place to the other
<FromGitter> <bew> true, I saw your issue afterward, we'll see where it's going!
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 265 seconds]
alexherbo2 has quit [Ping timeout: 246 seconds]
<raz> UnsolvedCypher_gitlab: might be your chance to enter the crystal hall of fame with a PR :)
alexherbo2 has joined #crystal-lang
<raz> hum, still struggling with basic typedefs :/
<FromGitter> <Blacksmoke16> https://carc.in/#/r/930d
<raz> Blacksmoke16: you could at least be so polite as too ask me a question before making me look like a noobie :P
<raz> let me ask*
<FromGitter> <Blacksmoke16> 😎
* raz bows :p
<FromGitter> <Blacksmoke16> otherwise since the hash doesnt have n Int32 value, its missing that type
<FromGitter> <Blacksmoke16> so using that syntax "casts" it to the proper type, even if they are not all present
<FromGitter> <Blacksmoke16> id make an alias for the hash tho to make it a bit easier to use
<raz> yea, i was trying to do that with as, glad to learn there's a syntax for it that actually works! :D
<raz> hmmm
<raz> how do i even pass an alias to a Hash tho
* raz scratches head
<FromGitter> <Blacksmoke16> Huh?
<FromGitter> <Blacksmoke16> what are you trying to do?
<raz> basically just trying to apply it with from_json
<FromGitter> <Blacksmoke16> well `from_json` expects a `String | IO` tho?
<raz> yea sorry, to_json missng in there, sec
<raz> ok... then it just works... duh
* raz crawls back into his corner
<FromGitter> <Blacksmoke16> mhm
<FromGitter> <Blacksmoke16> :p
<raz> still on the casting couch. :/
<FromGitter> <ImAHopelessDev_gitlab> pretty sure i had that issue long time ago
<FromGitter> <ImAHopelessDev_gitlab> something to do with unions with hashes
<raz> yea i wonder if that cast was just never possible, or if i'm missing sth obvious
<FromGitter> <ImAHopelessDev_gitlab> not an "issue" per say, but misunderstanding
<FromGitter> <ImAHopelessDev_gitlab> something like `alias Gubby = Hash(String, String) | Hash(String, Int32)`
<FromGitter> <ImAHopelessDev_gitlab> need to create union for the other hash iirc
<raz> yup but that's what i'm trying to avoid, or i would have to list all possible permutations
<raz> (when there's more than 2 types or it gets nested)
<FromGitter> <ImAHopelessDev_gitlab> oh yeah, sometimes its a bit messy
<FromGitter> <ImAHopelessDev_gitlab> that's what i was trying to do as well
<FromGitter> <ImAHopelessDev_gitlab> then i was like f this, and just listed them all out
<raz> jhass: cheater!
<raz> point is i'm getting that hash from elsewhere. i don't want that source to know or care that it's a Gubby ;)
<jhass> well
<raz> it's in fact not even a literal, it's coming from_json
<jhass> why's it important to cast it into a gubby then?
<FromGitter> <naqvis> https://carc.in/#/r/931d
<FromGitter> <naqvis> kind of cheating though 😆
<FromGitter> <ImAHopelessDev_gitlab> O_O
<raz> naqvis: yea i might go that route, very inefficient tho :(
<FromGitter> <ImAHopelessDev_gitlab> hacks
<FromGitter> <ImAHopelessDev_gitlab> reported to asterite
<FromGitter> <naqvis> hey Girng, long time no see
<FromGitter> <naqvis> lol
<FromGitter> <ImAHopelessDev_gitlab> ..oh wait :D
<jhass> I call XY question
<FromGitter> <ImAHopelessDev_gitlab> @naqvis hey Ali
<jhass> there's likely a design where you just don't need to do that
<FromGitter> <naqvis> hey Girng
<FromGitter> <naqvis> https://carc.in/#/r/931g
<raz> jhass: hmm good point. guess i'm trying to be a bit more generic than i should (altho it would be awfully convenient if the above just worked). it's complicated to explain :/ - basically the data travels through json and i'm trying sub-keys to various places that know what they allow and i'm trying to codify that knowledge only there, otherwise i'd bleed into all kinds of places.
<raz> oh well, i'll fiddle around some more ;)
deavmi has quit [Quit: Eish! Load shedding.]
<raz> naqvis: hmmm!
<FromGitter> <naqvis> 😆
<FromGitter> <naqvis> you just need to be explicit
<raz> ha, that might actually work
<jhass> you say it would leak to various places, I say defining a full model is actually a benefit and makes your code clearer than opaque hashes that you don't really know what they contain anymore at some point
deavmi has joined #crystal-lang
<FromGitter> <naqvis> totally agree with jhass comments
<FromGitter> <naqvis> but jhass, there are sometime use-cases where one might need to write a generic ADT
<FromGitter> <naqvis> like `Any` used in stdlib
<jhass> then use Any :)
<FromGitter> <naqvis> language is providing the `Union` type, so there might be use-cases for the same
<jhass> don't make your own subset type just because
<jhass> your serialization choice is the upper bound of possible types, handle them
<FromGitter> <naqvis> agree
<raz> in principle you are of course right. in practice... oh well, these rare cases exist where you can only anticipate the structure of the data but not all types/keys that may appear (e.g. when the data is generated by other systems).
<FromGitter> <ImAHopelessDev_gitlab> guard clauses = 😍💕
<jhass> that's just confirming my argument?
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> `.as()` is mainly used for resolving unions to a more specific type. Not really changing the type of one thing to another
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <naqvis> true and it will trigger exception if var isn't that particular type
<FromGitter> <naqvis> and btw compiler won't allow unrelated type conversions
<jhass> Now for generics, think about this: reference types, each union type and each value type have a different memory layout
<jhass> casting is interpreting the underlying bytes as a different type
<jhass> it does not convert the type
<jhass> it does not change the memory layout
<jhass> often it simply cannot, the compiler wouldn't know how
<FromGitter> <naqvis> but there is no casting in crystal
<jhass> .as totally is casting
<FromGitter> <naqvis> ```code paste, see link``` ⏎ ⏎ straight from the reference docs [https://gitter.im/crystal-lang/crystal?at=5ec0332d863019312a637286]
<FromGitter> <naqvis> ```code paste, see link```
<jhass> yes there's too many languages that call conversion casting unfortunately :/
<jhass> but it is casting in crystal, it changes how the bytes are interpreted
<FromGitter> <naqvis> true, lol
<FromGitter> <naqvis> aahh
<FromGitter> <naqvis> then i would say, reference docs aren't representing that correctly
<jhass> it just has some additionaly safety inbuilt in some cases
<jhass> but if you roundtrip through pointers you could cast anything to anything
<FromGitter> <naqvis> or at least for me, till now i had this impression that there is no conversion/casting in crystal
<jhass> conversion is explictly there on the type
<FromGitter> <naqvis> yeah, pointer stuff is different
<jhass> 12.to_i64 is conversion
<FromGitter> <naqvis> but doesn't that fall under `unsafe` context?
<jhass> I'd say safe/unsafe is orthogonal
<jhass> a cast can be safe or unsafe, sure
<jhass> Array(String|Int32).new.map(&.as(String)) is casting the values but converting the array
<FromGitter> <naqvis> that because Int32 supports that
<jhass> what?
<jhass> the .as operations on the union type in the example above
<jhass> not on String or Int32
<FromGitter> <naqvis> gotcha
deavmi has quit [Quit: Eish! Load shedding.]
<FromGitter> <naqvis> but isn't `as` going to validate the type?
<FromGitter> <Blacksmoke16> there is also `.as?()`
<FromGitter> <Blacksmoke16> returns `nil` if it couldnt be casted versus exception
<FromGitter> <naqvis> when dealing with union types, any value falling under union is going to be accepted by .as
<FromGitter> <naqvis> question would be, using `.as` on Union type is going to bring any consequences?
<jhass> what kind of consequences do you mean?
deavmi has joined #crystal-lang
<FromGitter> <naqvis> data loss?
<FromGitter> <naqvis> memory corruption?
<jhass> no
<jhass> memory corruption only for the (unsafe) pointer casts
<FromGitter> <naqvis> yeah, that's understood
<jhass> the runtime verification is mostly for casting parent typed variables to their child classes
<FromGitter> <naqvis> but union can be applied to any type
<FromGitter> <naqvis> though top above the hierarchy they fall under Object
<FromGitter> <naqvis> but in general they don't have any relationship
<jhass> so?
<jhass> (I said mostly because I'm not sure but I cannot come up with any other cases right now)
<jhass> oh wait, no of course it's for unions too
<jhass> nvm that one :D
<FromGitter> <naqvis> this discussion started on the topic of Union and narrowing down the types to fall under union using the '.as`
deavmi has quit [Quit: Eish! Load shedding.]
<FromGitter> <naqvis> so would like to continue this discussion to learn more (if you don't mind ofcourse)
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec036f9eb9b6f316228a3e8]
<FromGitter> <naqvis> what problem could arise of using `.as` in this scenario?
deavmi has joined #crystal-lang
<jhass> in this literal scenario? none
<jhass> but it's also pretty pointless and too simplified from any real world usecase
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec03756e6f167317505104c]
<FromGitter> <naqvis> then question would, why compiler isn't able to infer the type in this scenario?
<FromGitter> <naqvis> value type is indeed one of the Union type
<jhass> say a = "foo"; b = "foo".as(String|Int32). Can you see a and b having different memory layouts?
<FromGitter> <Blacksmoke16> my guess would be `.as` can only *reduce* the types, not add types to it?
<FromGitter> <naqvis> they do and definitely do
<jhass> so, you also see Hash(String, String) and Hash(String, String|Int32) having different memory layouts?
<jhass> doesn't it make sense that you can not insert a String|Int32 into something with memory layout for String?
<jhass> but that's what you're asking Crystal to allow with that cast
<FromGitter> <naqvis> hmmm
<FromGitter> <naqvis> is crystal union concept different than C one?
<FromGitter> <naqvis> now i start doubting my understanding of UnionType concept in Crystal
<jhass> I'm not sure I'm intimately familar enough with either one confidently answer this, but I think it's very similar. Crystal unions just always have a tag for the runtime value that's in the union
<jhass> so String|Int32; is something like struct { int tag; union { char* string; int number } value }
<jhass> don't nail me on the order of the struct fields
<FromGitter> <naqvis> can you please help to shed some light on the rationale behind having this UnionType addition to language?
<jhass> I think initially it was just a smart solution to having a type annotation free but statically typed language
<FromGitter> <naqvis> make sense
<jhass> and I think it still avoids a lot of boilerplate
<jhass> and just generalizes the solution to having a null type
<jhass> that is making String and String? different types
<jhass> btw unions between reference types and nil are just represented as the pointer in memory, the nil value is represented as a null pointer
<jhass> neat little optimization
deavmi has quit [Quit: Eish! Load shedding.]
<jhass> I mean how would you do a map or list type supporting mixed types in their values? Either you force the user to use the most general common type (Object) or you have them declare a union type explicitly
<jhass> * in other languages I wanted to say
deavmi has joined #crystal-lang
<FromGitter> <naqvis> personally i prefer to go via interfaces other than concrete types
<FromGitter> <naqvis> yeah i understand the benefit, but the cost is also not little in Union types
<FromGitter> <naqvis> as one need to do switch to understand what he/she is dealing with
<jhass> (english language protip: https://en.wikipedia.org/wiki/Singular_they)
<jhass> wasn't much of an issue for me, but then I come from dynamically typed languages :)
<FromGitter> <naqvis> thanks lol
<jhass> I think union types are actually the one thing that transport the haptics of dynamically typed languages best to the statically typed world
<jhass> for me
<FromGitter> <naqvis> agree
<FromGitter> <naqvis> thanks jhass and it was a great session for me
<jhass> <3
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <rishavs> Dumb question time, but in the issue https://github.com/crystal-lang/crystal/issues/6957 about adding event loop to Windows, why are we not considering using libuv, instead of working directly with IOCP? maybe even remove libevent from crystal in favor of libuv altogether? Libuv is cross plat and even .nets kestrel server uses it. ⏎ I think i might be missing something very obvious
<FromGitter> <rishavs> Thank you!
<oprypin> rishavs, doesnt the issue itself that you're linking say why it's not useful
Jenz has joined #crystal-lang
<Jenz> How do I link to a local c lib, "extern/mylib.{c,h}" ?
<Jenz> Without having the faintest idea what I'm doing, I tried @[Link("extern/mylib.h")], to no avail
<oprypin> Jenz, .h is never used and .cpp needs to be compiled into .o first and that one is linked
<Jenz> Aha! Then how do I link to the .o file? XD
<oprypin> `@[Link(ldflags: "#{__DIR__}/extern/mylib.h")]`
<oprypin> Jenz, or make a proper `.so` library out of it and `@[Link("mylib")]`
<Jenz> I take that's s/\.h/\.o/ ?
<oprypin> yes
<Jenz> Thanks, oprypin
<oprypin> Jenz, it was quite a nice revelation for me srsly that i dont need to produce a .h file :D crystal's lib definitions completely replace it
* Jenz ^^
<Jenz> crsfml is probably the crystal shard I've had to most fun with, and I'm looking forward to even more!
<Jenz> In fact what I'm trying to link to now, HSLuv is a color model library I'm plannig to use with crsfml
hightower2 has joined #crystal-lang
<hightower2> Hey how come that even the master branch of kemal requires kilt ~> 0.4.0, which doesn't have exhaustive else so compilation fails
<FromGitter> <grkek> wow thats sad, use grip haha
<hightower2> from what I see, there are commits going in into the kemal repository, it's not obviously out of date
<oprypin> hightower2, uh what exhaustive case doesnt fail compilation
<hightower2> oprypin,aah, indeed.. overlooked that fact, thanks
<oprypin> also on crystal master even the warnings about exhaustive case are removed
<hightower2> how come, just removed for good, or the alternative was accepted to have one notation for exhaustive and one for normal?
Jenz has quit [Quit: leaving]
<oprypin> latter
hightower2 has quit [Ping timeout: 256 seconds]
_ht has quit [Quit: _ht]
<oprypin> aaaa why is MULTILINE broken https://crystal-lang.org/api/0.34.0/Regex/Options.html
<oprypin> i basically always want PCRE_MULTILINE and basically never want PCRE_DOTALL
<oprypin> mixing them is what i refer to as broken, sorry
<oprypin> straight-shoota, do we have any way to write win32-specific specs?
<straight-shoota> {% if flag?(:win32) %} describe "win32" do end {% end %}
<straight-shoota> or {% skip_file unless flag?(:win32) %}
<straight-shoota> Do you mean that?
<oprypin> straight-shoota, i mean just one test
<oprypin> i guess it makes sense to just `{% if flag?(:win32) %}`. kinda verbose though
<straight-shoota> yes, that's best
<straight-shoota> there should be quite a few specs like that for different platforms
<straight-shoota> the only shortcut is pending_win32 because that's all over the place. Or used to be.
sz0 has quit [Quit: Connection closed for inactivity]
rocx has quit [Quit: 👏 developers 👏 developers 👏 developers 👏 developers 👏 developers]
alexherbo2 has quit [Ping timeout: 264 seconds]