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> <Blacksmoke16> ❤️ @HertzDevil, I'll take a look later tonight
<FromGitter> <HertzDevil> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=606cf7df89446618e98deb08]
<FromGitter> <HertzDevil> ?
<FromGitter> <oprypin:matrix.org> @HertzDevil: ohh under *that* interpretation of the question. maybe that actually works, yea
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> @HertzDevil I think the problem is the type of these things is `Alias` not `AliasType` which doesnt have those methods
<FromGitter> <HertzDevil> `Alias` has #resolved_type` also
<FromGitter> <Blacksmoke16> omg it can be that easy
<FromGitter> <Blacksmoke16> cant*
<FromGitter> <Blacksmoke16> wow ok, specs passed with that. I assumed that to be the resolved type the alias points to :/
<FromGitter> <Blacksmoke16> now what about annotations, given it doesnt have either of those. Just need to do something similar as what alias has?
<FromGitter> <HertzDevil> yeah add a `resolved_type` to `AnnotationDef` instead of `owner`
<FromGitter> <Blacksmoke16> easy enough, sec
<FromGitter> <Blacksmoke16> that ended up being a lot simpler than i was expecting
<FromGitter> <HertzDevil> actually wait
<FromGitter> <HertzDevil> are you emitting the warnings at the use site or the definition site
<FromGitter> <Blacksmoke16> where the alias/annotation is defined
<FromGitter> <HertzDevil> but deprecation warnings occur at the former, not the latter
<FromGitter> <Blacksmoke16> ah rip, which is diff than how the others work
<FromGitter> <Blacksmoke16> yea :/
<FromGitter> <HertzDevil> should be checking `#annotations` for types that are `Annotatable`
<FromGitter> <HertzDevil> aliases i don't know where to check
<FromGitter> <HertzDevil> might need to add a `#visit` overload
<FromGitter> <Blacksmoke16> def/macros are based on a `Call`, which makes sense why it reports at the call site
<FromGitter> <Blacksmoke16> uh oh :grimm
<FromGitter> <HertzDevil> and that check needs to exclude the alias's own name, obviously
<FromGitter> <HertzDevil> if you have `@[Deprecated] alias A = Int32 | Array(A)` then the deprecation should ideally be reported at the second `A` but not the first
<FromGitter> <Blacksmoke16> and anywhere else `A` is used
<FromGitter> <HertzDevil> yeah in that case the lookup probably produces the `AliasType` directly, so you don't need `resolved_type` there
<FromGitter> <HertzDevil> but annotations still need that
<FromGitter> <Blacksmoke16> unfortunately we're a bit beyond my area of understanding. I'd be fine if you wanted to take over the PR otherwise might take me a while...
<FromGitter> <Blacksmoke16> the line in the warning is also wrong, so now that i look at it again im prob processing the wrong node or something?
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 250 seconds]
f1reflyylmao is now known as f1refly
chachasmooth has quit [Ping timeout: 246 seconds]
chachasmooth has joined #crystal-lang
_ht has joined #crystal-lang
<FromGitter> <naqvis> > wondering which stdlib feature will be first that uses the `@[Experimental]` annotation ⏎ ⏎ Labeled loops? so that one can exit out of nested loop (if any) :P
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
ua has quit [Ping timeout: 240 seconds]
zorp has quit [Read error: Connection reset by peer]
ua has joined #crystal-lang
hendursa1 has joined #crystal-lang
hendursaga has quit [Ping timeout: 240 seconds]
raz has quit [Ping timeout: 248 seconds]
libneko[m] has quit [Ping timeout: 248 seconds]
raz has joined #crystal-lang
libneko[m] has joined #crystal-lang
shalokshalom has quit [Quit: https://quassel-irc.org - Komfortabler Chat. Überall.]
andremedeiros has quit [Quit: ZNC 1.8.2 - https://znc.in]
andremedeiros has joined #crystal-lang
HumanG33k has quit [Ping timeout: 240 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
postmodern has joined #crystal-lang
yxhuvud has quit [Ping timeout: 258 seconds]
yxhuvud has joined #crystal-lang
<FromGitter> <riffraff169> a question, what is the point of annotations? from some of the things ive seen, they can be implemented as just other vars or something in the class....am i missing something?
<FromGitter> <erdnaxeli:cervoi.se> their only point is to be used by macros
<FromGitter> <erdnaxeli:cervoi.se> or the compiler
<FromGitter> <riffraff169> ah, so no real user/in program point...ok sure
<FromGitter> <erdnaxeli:cervoi.se> at runtime there are useless, and the compiler probably removes them from the final binary
<FromGitter> <riffraff169> maybe someday ill get to that point
<FromGitter> <riffraff169> but not today
hightower2 has joined #crystal-lang
<FromGitter> <lodenos> Hello guy’s, I’ve a question about `IO::Memory#new(capacity : Int = 64)` if I write ⏎ ⏎ ```mem = IO::Memory.new 1024``` [https://gitter.im/crystal-lang/crystal?at=606db17238f85428539ffa66]
<FromGitter> <naqvis> capacity is not size
<FromGitter> <naqvis> capacity is the initial buffer which get allocated
<FromGitter> <naqvis> size represents what's inside that buffer
<FromGitter> <lodenos> Ok but that’s mean if we write biger than 1024 Memroy realloc automatly ?
<FromGitter> <naqvis> yeah
<FromGitter> <naqvis> default capacity is 64
<straight-shoota> depends on how you create the IO::Memory
<FromGitter> <naqvis> but if you know the size in advance and don't want re-allocation to happen then you can create one with desired capacity
<straight-shoota> but with that constructor it's resizable: https://crystal-lang.org/api/1.0.0/IO%2FMemory.html#new(capacity:Int=64)-class-method
<FromGitter> <lodenos> the GC realloc by multiply of 1024 in my exemple or it’s the GC do the staff alone beside
<FromGitter> <naqvis> should be GC side
<FromGitter> <naqvis> `IO::Memory` doesn't re-allocate in multiples of any number
<FromGitter> <naqvis> but it take the `ceil(current_position + written_bytes_size)`
<FromGitter> <lodenos> Hum I’ve a friend want to be sure isn’t realloc all the time for optimise the speed
<FromGitter> <lodenos> Ho I see thx
<FromGitter> <djberg96> just curious, what would the crystal equivalent of this Go snippet be?
<FromGitter> <djberg96> `func addMatrices(m1 [][]int, m2 [][]int) [][]int {`
<FromGitter> <djberg96> is there a way to declare a type of array of array of ints?
<FromGitter> <Blacksmoke16> `Array(Array(Int32))`
<FromGitter> <Blacksmoke16> > ah, so no real user/in program point...ok sure ⏎ ⏎ that's not entirely true imo
<FromGitter> <Blacksmoke16> annotations are a great way to store "metadata" about an ivar/class/method that can later be consumed in a macro for more advanced metaprogramming
<FromGitter> <MrSorcus> @djberg96 see also https://crystal-lang.org/reference/syntax_and_semantics/alias.html for not typing `Array(Array(Int32))` 3 times.
<FromGitter> <Blacksmoke16> athena uses them extensively as a DSL that otherwise would have to be some form of macro DSL
<FromGitter> <Blacksmoke16> e.g. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=606db8c1fb5e057df3a14b18]
<FromGitter> <Blacksmoke16> they're not something you'd want to use all the time, but is good to keep in mind
<FromGitter> <riffraff169> ah...
sz0 has joined #crystal-lang
<FromGitter> <djberg96> @MrSorcus thanks
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
avane has quit [Quit: o/]
avane has joined #crystal-lang
hendursa1 has quit [Ping timeout: 240 seconds]
<FromGitter> <riffraff169> if a class is in a module, does it inherit all the `@vars` from the module, like this?
<FromGitter> <riffraff169> ```module Test ⏎ @var = 12 ⏎ class Tester ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=606dcb2e309a8672cc081e0c]
<FromGitter> <Blacksmoke16> no
<FromGitter> <riffraff169> does `Tester` have access to `@var` directly
<FromGitter> <riffraff169> no, has to include still?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> modules are also used as namespaces, so all that does is namespace the `Tester` class
<FromGitter> <riffraff169> so `class Tester; include Test`
<FromGitter> <Blacksmoke16> yes, but whats the end goal here? wanting to share an ivar between multiple types?
r0bby has quit [Ping timeout: 260 seconds]
sz0 has quit [Ping timeout: 258 seconds]
sz0 has joined #crystal-lang
r0bby has joined #crystal-lang
hendursa1 has joined #crystal-lang
<FromGitter> <riffraff169> i was just namespacing, but i think there might only be one class in the module, so i could just put those vars in the class itself
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> fwiw normally you should namespace all your things, not have one namespace pertype
<FromGitter> <Blacksmoke16> like `module MyLib` then all your stuff lives in that namespace
<FromGitter> <riffraff169> this is an evolving project, figuring out how i want to arrange it all together
<FromGitter> <riffraff169> but you can have the module referenced in multiple files, and it adds them all to the same module, right?
<FromGitter> <Blacksmoke16> right yes
<FromGitter> <Blacksmoke16> you can also do like `class MyLib::MyClass`
<FromGitter> <riffraff169> ah, that will work too
<FromGitter> <Blacksmoke16> which creates `MyLib` as a module if it hasnt already been and puts `MyClass` within in it
<FromGitter> <Blacksmoke16> versus nesting a bunch of `module X`
<FromGitter> <riffraff169> is it a pattern to create `MyLib` in a separate file, then add it with all the others...or just reference it as `MyLib::MyClass` to automatically create it
<FromGitter> <riffraff169> or probably doesnt matter
<FromGitter> <Blacksmoke16> i usually define it in the name `src/my_lib.cr` file
<FromGitter> <riffraff169> that also lowers the amount of indentation and whitespace
<FromGitter> <Blacksmoke16> then use that for documentation/other types that live in that root namespace
<FromGitter> <riffraff169> just out of curiosity, if you have a bunch of files, and you do `shards build` to create the final library or binary, if you change one file, does it compile everything from scratch again, or only the one file that changed
<FromGitter> <riffraff169> like c with .o files
<FromGitter> <Blacksmoke16> some things are cached but pretty much a full rebuild
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/10568#issuecomment-813494541 is a good example as to why that is
<FromGitter> <Blacksmoke16> and why incremental compilation is hard
<FromGitter> <riffraff169> yeah, c++ is different, not dynamic at all, so it knows everything up front all the time...
<FromGitter> <riffraff169> i see
<FromGitter> <riffraff169> one of the difficulties...you change class x, class y uses it, class z uses y, class a uses z, down a few more times...
<FromGitter> <riffraff169> change x, even though a doesnt use x, it still needs to be recompiled to match signatures up and down the line
<FromGitter> <ryanstout> I'm trying to create a table with arrays of arrays of a certain type, is there a way to do of `Array(UInt8)` or similar without adding _u8 to each literal?: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=606de436649e837de5ad534f]
<FromGitter> <ryanstout> I might be missing the obvious here
<FromGitter> <Blacksmoke16> try `a = [[1, 2, 3] of UInt8]` maybe?
<FromGitter> <Blacksmoke16> oh wait
<FromGitter> <Blacksmoke16> ```a = [[1, 2, 3] of UInt8] ⏎ b = [UInt8[1, 2, 3]]``` ⏎ ⏎ Both of these work [https://gitter.im/crystal-lang/crystal?at=606de55dabf94b631dc1cc59]
<FromGitter> <ryanstout> ok, that works I guess. Just doing a big nested table. Better than changing each literal though. Thanks!
sz0 has quit [Quit: Connection closed for inactivity]
ua has quit [Ping timeout: 252 seconds]
ua has joined #crystal-lang
<_ht> I cannot include a module in an enum?
<_ht> Is it possible to share functionality between multiple enums? For example, using "subclassing", or including a module?
<FromGitter> <oprypin:matrix.org> _ht, if you cannot include then maybe not. but you can always duplicate those functions. and uhh a macro can make it look like you're not duplicating anything
<_ht> Sure
ua has quit [Ping timeout: 240 seconds]
<_ht> I see this feature has already been implemented :-)
<FromGitter> <Blacksmoke16> has it? PR was closed it looks like
<_ht> Oh, then I misread that thread :-(
<_ht> On the other hand, it does say " wontruefree approved these changes on Mar 26, 2020". That does not mean the changes were actually merged into the project?
<FromGitter> <Blacksmoke16> no
<FromGitter> <Blacksmoke16> PR approval isn't the same as merging
<_ht> So, the best way to go is with @oprypin's solution and use a macro?
<FromGitter> <Blacksmoke16> probably
<FromGitter> <oprypin:matrix.org> _ht, literally anyone can go there and "approve these changes" :D
* _ht is off to aprove all the things!
<FromGitter> <oprypin:matrix.org> _ht, in Crystal it needs two core team member approvals - their approvals show up in green color
<_ht> Aha, makes sense
<FromGitter> <oprypin:matrix.org> oh god i just found that C bindings FFI is bugged not only on non-typical platforms
ua has joined #crystal-lang
<FromGitter> <oprypin:matrix.org> wait no, i had already found it before :D :D https://github.com/crystal-lang/crystal/issues/9519
_ht has quit [Remote host closed the connection]
hightower2 has quit [Ping timeout: 240 seconds]
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang