jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | 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> <watzon> `not_nil!` should be avoided
<FromGitter> <watzon> Much better to use a guard clause
<FromGitter> <watzon> ```if server = @server ⏎ # do something ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ff8f267d5f4bf2965d519ef]
<sagax> ok, thanks
<FromGitter> <watzon> There is also the `getter!` and `property!` macros which do use `not_nil!`under the hood, but make things a bit cleaner if you are in one of those situations where you need a nilable type but know for sure it won't be nil. So you can do: ⏎ ⏎ ```property! server : HTTP::Server? ⏎ # ... ⏎ server.bind_tcp``` [https://gitter.im/crystal-lang/crystal?at=5ff8f2f999549911fc0e0641]
<FromGitter> <watzon> `not_nil!` can byte you in the ass though
<sagax> it's very simple example https://susepaste.org/59750706
<sagax> what right way if i need variable with nil type `?` ?
<sagax> simple check like as `somevar.nil?` not work
<FromGitter> <Daniel-Worrall> You need to assign it to a local value to nil check an instance variable
<FromGitter> <3n-k1> > @3n-k1 so you figured it out? ⏎ sure did, forgot that `macro; end` is a thing lol
<FromGitter> <Daniel-Worrall> Sagas
<FromGitter> <Daniel-Worrall> Sagax
<FromGitter> <3n-k1> anyway, i'm trying to get a list of all built-in classes in crystal. currently just doing `{{Object.all_subclasses}}` but that's kinda hacky and super fragile because it has to run before any other class definitions. is there a better way to go about this?
<sagax> `.try` work
<FromGitter> <Blacksmoke16> @3n-k1 that ofc is also going to include custom classes
<FromGitter> <Blacksmoke16> whats your use case/
deavmi has quit [Ping timeout: 272 seconds]
<sagax> how to write `limitations` shorty?
<FromGitter> <Blacksmoke16> Hm?
<sagax> `if foo = @foo` or `@foo.try do |foo|`
<FromGitter> <Blacksmoke16> Depends on the context imo
deavmi has joined #crystal-lang
<FromGitter> <Blacksmoke16> `foo.try &.foo_method`
<FromGitter> <3n-k1> @Blacksmoke16 trying to create a gui version of `tool hierarchy` that doesn't include builtin classes
<FromGitter> <Blacksmoke16> Gl
<FromGitter> <3n-k1> current plan is to get builtin classes at compile time, then use `tool hierarchy` and filter out builtins
<FromGitter> <3n-k1> could also just run `tool hierarchy` twice, once on an empty file, and then diff the trees
<FromGitter> <3n-k1> that sounds hackier but also much easier
<FromGitter> <3n-k1> i *guess* i could also use a macro to run the empty `tool hierarchy` at compile time
<FromGitter> <watzon> @sagax I highly recommend using https://carc.in for Crystal example code
<FromGitter> <watzon> Makes it easier to test and share better ways of doing things
<sagax> thansk!
<FromGitter> <3n-k1> carc.in is only temporary though, right?
<FromGitter> <watzon> Not as far as I know
alexherbo2 has quit [Ping timeout: 246 seconds]
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 264 seconds]
<FromGitter> <mattrberry> In case anyone wants to see progress on my crystal gba emu :) https://drive.google.com/file/d/1H1c4P_YbYlX73aNX4V1njeM_ktKKpBcx/view?usp=sharing
<FromGitter> <mattrberry> My favorite part about emudev communities is the totally broken emulator screenshots/videos, so I figured I'd share some of that here :)
<FromGitter> <3n-k1> i'm amazed at how close that is, and also how ridiculously broken it is
avane has quit [Ping timeout: 240 seconds]
avane has joined #crystal-lang
avane has quit [Client Quit]
avane has joined #crystal-lang
<FromGitter> <watzon> That's a thing of beauty @mattrberry
Volk has quit [Quit: See you next time!]
richbridger has quit [Read error: Connection reset by peer]
<FromGitter> <mattrberry> I haven’t don’t any affine transformations yet, which causes the broken sprites and Pokémon logo haha. Also need proper hdma to get the clouds to be wavy on the title screen
<FromGitter> <mattrberry> And the broken placement of rayquaza‘a beam, plus the groudon and kyogre scenes
_whitelogger has joined #crystal-lang
aerona has joined #crystal-lang
aerona has quit [Client Quit]
deavmi has quit [Ping timeout: 272 seconds]
_ht has joined #crystal-lang
postmodern has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
<hightower2> Uhmm... why wouldn't this work: https://carc.in/#/r/a8pl
<hightower2> ah I see, the all=0 should be all with no default value
<hightower2> hm, still an issue
<hightower2> it works if I change the order of initializes. Is that expected?
<oprypin> hightower2: like, u realize that a call with 1 arg matches both methods?
<oprypin> then yes the order comes into play, that's normal i think
<hightower2> ok, thanks
alexherbo2 has joined #crystal-lang
<hightower2> oprypin, even though, my example called it with 4 args
<hightower2> didn't realize up to now that that's how resolution worked
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
<oprypin> hightower2: hmm i also didn't properly check what you were trying to show. that *is* weird
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<oprypin> probably specific to initialize, too
<hightower2> Hm seems general? https://carc.in/#/r/a8r9
<oprypin> yes https://carc.in/#/r/a8rb nvm
<hightower2> pretty interesting
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 260 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
ua has quit [Ping timeout: 240 seconds]
deavmi has joined #crystal-lang
ua has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
Volk has joined #crystal-lang
ua has quit [Ping timeout: 264 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
ua has joined #crystal-lang
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 240 seconds]
ua has quit [Ping timeout: 256 seconds]
ua has joined #crystal-lang
Stephie has quit [Read error: Connection reset by peer]
Stephie has joined #crystal-lang
DTZUZU has quit [Ping timeout: 246 seconds]
DTZUZU has joined #crystal-lang
deavmi has joined #crystal-lang
ua has quit [Ping timeout: 246 seconds]
<FromGitter> <HertzDevil> `Crystal::Type#parents` only includes the direct superclass and directly included modules, right
<FromGitter> <HertzDevil> because it seems indirect ones are covered by `#ancestors` (the same one provided by `TypeNode`)
ua has joined #crystal-lang
deavmi has quit [Ping timeout: 246 seconds]
<oprypin> i dont know but sounds sensible
ua has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
V[excess] is now known as ^
ua has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
<sagax> what different between `struct` and `class` ?
<FromGitter> <Blacksmoke16> structs are allocated on the stack while classes are allocated on the heap
<FromGitter> <Blacksmoke16> related, structs are passed by value, while classes are passed by reference
<FromGitter> <Blacksmoke16> normally you want to use structs for small immutable objects
<FromGitter> <Blacksmoke16> that tend to be created/deleted often as the GC wont need to track them
richbridger has joined #crystal-lang
<FromGitter> <erdnaxeli:cervoi.se> Struct does not need work from the gc
<FromGitter> <erdnaxeli:cervoi.se> (plus everything @Blacksmoke16 says)
deavmi has quit [Ping timeout: 246 seconds]
<sagax> abstract class it's like interface?
<FromGitter> <Blacksmoke16> a module would be more similar to that
<FromGitter> <Blacksmoke16> as it could be added to both classes and structs (and other modules)
<FromGitter> <jrei:matrix.org> abstract class/struct forces you to use class/struct, which can be a good/bad thing. Depends of what you want to do
<FromGitter> <Blacksmoke16> also keep in mind you can inherit from both classes and abstract classes but you can only inherit from abstract structss
<FromGitter> <jrei:matrix.org> Right. What is the explanation behind?
<FromGitter> <Blacksmoke16> something about the memory layout of it needs to be known
<sagax> crystal have something like as `irb` or `pry`? i understand that crystal it's compiled language, but maybe we have something tools
<FromGitter> <Blacksmoke16> there is https://github.com/crystal-community/icr
<FromGitter> <Blacksmoke16> `crystal play` is also an option, or just have a `test.cr` file and keep running it
<sagax> thanks
<oprypin> watzon, do you mind if i link to your website as part of "showcase" for the doc generator
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <watzon> Of course not
<FromGitter> <watzon> By all means
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
ua has quit [Ping timeout: 256 seconds]
<FromGitter> <jrei:matrix.org> Good work oprypin! I still find it harder to browse than the classic API docs
<FromGitter> <jrei:matrix.org> In the middle of a doc page, it is not clear if the method definition is the one above or below
<FromGitter> <jrei:matrix.org> Ha i see you added a view-source link
<FromGitter> <watzon> I feel like the background color I gave method definitions in my docs helps a bit with that
<FromGitter> <watzon> Though maybe I should indent the descriptions a bit as well
Volk has quit [Quit: See you next time!]
<oprypin> jrei:matrix.org, styles are pretty much all default. in fact, *I* can't add new defaults. but anyone can style this in any way they want
<FromGitter> <jrei:matrix.org> I agree @watzon , that's even better!
<FromGitter> <jrei:matrix.org> Compared to Athena, yours is a lot more readable thanks to code blocks and view-source. However, no dark theme
<FromGitter> <watzon> What I need is a way to toggle the dark and light theme
<FromGitter> <watzon> Do you know if there is a built in way to do that with the material theme @oprypin?
<oprypin> gotta pay 10 euros for that lol
<FromGitter> <watzon> Ahh is it a part of the insiders stuff?
<sagax> i read docs, but don't understand when i must user `property` and when i must use `getter` ?
<sagax> use*
<oprypin> sagax, property = getter + sette
<sagax> hm, i just don't see examples with `setter`
<oprypin> it's super rare to have a setter without getter, so yea
<FromGitter> <watzon> Yeah `getter` defines a `def {{ name }}` method while property defines that, and `def {{ name }}=(value)`
<FromGitter> <watzon> Setters definitely aren't super common. Usually you either want a property to just be accessible, or for it to be accessible and settable.
ua has joined #crystal-lang
<FromGitter> <kingsleyh> hello - my builds keep failing intermittently on Travis CI with `Invalid memory access (signal 11) at address 0x7fab39fd0818` - does anyone else have this issue? and any suggestions what to do about it? I get the feeling it's running out of memory when compiling or something like that
<FromGitter> <kingsleyh> also does anyone use github actions instead of Travis? does it work ok with Crystal?
<FromGitter> <oprypin:matrix.org> @kingsleyh yes everyone uses GitHub actions
<FromGitter> <kingsleyh> ok cool - maybe I will a better experience with that over Travis then
deavmi has quit [Ping timeout: 256 seconds]
<FromGitter> <kingsleyh> awesome thanks :)
deavmi has joined #crystal-lang
_ht has quit [Remote host closed the connection]
deavmi has quit [Ping timeout: 272 seconds]
Volk has joined #crystal-lang
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
alexherbo24 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo24 is now known as alexherbo2
deavmi has joined #crystal-lang
Nekka has quit [Quit: zzz]
deavmi has quit [Ping timeout: 272 seconds]
Nekka has joined #crystal-lang
deavmi has joined #crystal-lang
<FromGitter> <3n-k1> yesterday i learned about affine transformations
<FromGitter> <3n-k1> whoops, i was scrolled *way* far back
Nekka has quit [Quit: zzz]
Nekka has joined #crystal-lang
Nekka has quit [Quit: zzz]
f1refly has quit [Ping timeout: 265 seconds]
f1refly has joined #crystal-lang
<hightower2> Is it expected that one can't call a method with double splat arg in this case: https://carc.in/#/r/a8tk