<postmodern>
how do you enforce that an ivar is never Nil?
<oprypin>
uhhh you declare its type to not include Nil ??
<postmodern>
trying to define @crc : UInt8 in a sub-class
<postmodern>
Error: instance variable '@crc' of Digest::CRC, with Digest::CRC8 < Digest::CRC, is already declared as (Int32 | Nil) (trying to re-declare as UInt8)
<raz>
property block : (-> Nil)?
<raz>
^ is there a way to change this line so that "block" can hold a Proc with any return type/
<raz>
i have a feeling it should be possible, but can't figure out a syntax that works. hm.
<oz>
raz: what about `property block : (->)?`
<raz>
oz: that... just works ¯\_(ツ)_/¯
<raz>
thank you
<raz>
aaand everything snaps into place
<raz>
crystal feels like a downhill battle
<oz>
it does sometimes :)
<postmodern>
i'm guessing "abstract constants" are not supported?
<raz>
don't think so, i've been in situations where i'd have liked them, too
<raz>
(but in hindsight they'd probably be a bad idea anyway)
<raz>
same for abstract methods btw. almost every time i used them, i'd later revert to a normal method.
<raz>
perhaps i just haven't found the proper secret sauce yet, tho
<postmodern>
yeah would like to my abstract class have methods that rely on constants that are defined in the sub-classes
<postmodern>
suppose the constants can just become abstract instance methods as well
<raz>
yep, i think that's what i have done most of the time
<postmodern>
are compiler annotations on abstract methods inherited when those methods are defined in the sub-classes?
<postmodern>
can you pass keyword arguments to a generic class definition, like Foo < Bar(UInt64, other_stuff: "here") ?
<postmodern>
what's the quickest way to convert the bytes in a UInt into a String?
teardown has quit [Read error: Connection reset by peer]
<postmodern>
wow wait, String#length isn't a thing in crystal?
<postmodern>
ah #size
<postmodern>
length is pretty common though...
<postmodern>
also wow what, Int32 / Int32 returns a Float32? Normally I'd expect that to round to an int
<postmodern>
also hmm, doesn't look like you can use macros (sizeof) on a generic type T
<postmodern>
or use generic types in a constant assignment
ur5us has quit [Ping timeout: 240 seconds]
<postmodern>
BUG: unknown node in TypeLookup: sizeof(UINT) SizeOf (Exception)
<postmodern>
i am really giving the type system a workout
<postmodern>
how do you define an abstract method which returns a static array of something, but you don't know the exact size yet?
teardown has joined #crystal-lang
ur5us has joined #crystal-lang
dwdv has joined #crystal-lang
<postmodern>
is there a crystal equiv of const_get ? i want to request a constant, and have it look at the class of the object, not the class the method was defined in
_ht has joined #crystal-lang
alexander92 has joined #crystal-lang
alexander92 has left #crystal-lang [#crystal-lang]
<postmodern>
https://carc.in/#/r/8myw having trouble defining a class property in a base class that uses a generic type
ur5us has quit [Ping timeout: 240 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 248 seconds]
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
DTZUZU has quit [Ping timeout: 260 seconds]
_ht has quit [Ping timeout: 246 seconds]
postmodern has quit [Quit: Leaving]
_ht has joined #crystal-lang
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 258 seconds]
HumanGeek has quit [Ping timeout: 255 seconds]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
DTZUZU has joined #crystal-lang
darkstardevx has quit [Remote host closed the connection]
sorcus has quit [Quit: WeeChat 2.7]
sorcus has joined #crystal-lang
renich has joined #crystal-lang
renich has quit [Ping timeout: 272 seconds]
Vexatos has quit [Remote host closed the connection]
Vexatos has joined #crystal-lang
<yxhuvud>
postmodern: Use // if you want an int back
<yxhuvud>
oh, he left
MasterdonX has quit [Ping timeout: 258 seconds]
MasterdonX has joined #crystal-lang
_whitelogger has joined #crystal-lang
ht_ has joined #crystal-lang
_ht has quit [Ping timeout: 246 seconds]
ht_ is now known as _ht
sagax has quit [Ping timeout: 265 seconds]
sagax has joined #crystal-lang
ur5us has joined #crystal-lang
_ht has quit [Quit: _ht]
postmodern has joined #crystal-lang
<postmodern>
hello, i'm trying to define a class variable in a generic class that uses the generic type. crystal kind infer the type though. is this even allowed at the class-level? https://carc.in/#/r/8n3j