<FromGitter>
<neutrinog> I don't want it to be tied to any particular class though
<FromGitter>
<neutrinog> or at most, only to a base class
<FromGitter>
<neutrinog> ah thanks @watzon. I can use that with a base class. That's perfect.
ur5us has joined #crystal-lang
_ht has joined #crystal-lang
<FromGitter>
<neutrinog> ok related question. Is there any way to pass a variable of type `Object.class` to a generic? e.g. https://play.crystal-lang.org/#/r/8x3y
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
ur5us has quit [Ping timeout: 252 seconds]
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 265 seconds]
<jhass>
neutrinog: No. Think about it, cls is a runtime value, how should the compiler type this if I do cls = rand > 0.5 ? String.class : Range.class?
<jhass>
however you may be able to use Generic(typeof(some_var)) in some cases
<yxhuvud>
There is also `Array(Int32){1,2,3}` which works on anything implementing `<<`
<yxhuvud>
though that might be answering a different question :P
<yxhuvud>
Actually, the (Int32) part doesn't seem to be necessary, so it may actually answer the right one :P
<jhass>
[1, 2, 3] and Array(Int32) { 1, 2, 3 } get rewritten to the same thing really. The latter syntax is just more general and works for any class
<yxhuvud>
Right.
<FromGitter>
<ImAHopelessDev_gitlab> hi
chachasmooth has quit [Ping timeout: 265 seconds]
<FromGitter>
<neutrinog> thanks that got me in the right direction.
ur5us has joined #crystal-lang
chachasmooth has joined #crystal-lang
MasterdonX has quit [Ping timeout: 256 seconds]
MasterdonX has joined #crystal-lang
alexherbo2 has joined #crystal-lang
zorp has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
ur5us has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
alexherbo24 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 264 seconds]
alexherbo24 is now known as alexherbo2
<FromGitter>
<kingsleyh> hi - when writing C bindings - if the function can take a NULL - e.g. `fun go(param : Void*)` - if I want `go(NULL) ` can I do `go(nil)` and it will get turned into NULL when it runs the binding?
<jhass>
yeah :)
<jhass>
Crystal codegens nil as a null pointer, so for Lib calls it just bypasses the semantic checks :)
<FromGitter>
<kingsleyh> thanks :)
zorp_ has joined #crystal-lang
zorp has quit [Ping timeout: 256 seconds]
<FromGitter>
<torvim> Can someone help me
<FromGitter>
<Blacksmoke16> with?
<FromGitter>
<torvim> i'm trying to find the dimensions of the user's terminal
<FromGitter>
<torvim> i've tried a few different solutions but none of them have worked
<FromGitter>
<kingsleyh> did I get this right? `int EVP_PKEY_get_raw_public_key(const EVP_PKEY *pkey, unsigned char *pub, size_t *len)` from C into Crystal: `fun EVP_PKEY_get_raw_public_key(pkey : Void*, pub : LibC::Char*, len : LibC::Int*) : LibC::Int`
<FromGitter>
<torvim> ayy i got it, nvm
<FromGitter>
<kingsleyh> or maybe it should be `len : LibC::SizeT*`
<jhass>
+1 for SizeT
<jhass>
unsigned char probably ought to be UChar
<jhass>
I don't know the rest of the API, but a type EvpKey = Void* might make things a bit neater and safer
<FromGitter>
<ImAHopelessDev_gitlab> good morning
<FromGitter>
<ImAHopelessDev_gitlab> crystal time baby
return0e has quit [Read error: Connection reset by peer]
<FromGitter>
<Blacksmoke16> yea i dunno, i didnt think that was possible, keep me posted :p
<FromGitter>
<neutrinog> I've never really grasped the concept of yield'ing, so I stuck with the familiar callback paradigm. I'm not sure yielding would work well in this case though since I want to subscribe to events. But maybe my thinking about yield's is all wrong.
<FromGitter>
<Blacksmoke16> working on an event dispatching lib?
<jhass>
I don't quite get where you expect the argument types to actually come from
hightower2 has quit [Remote host closed the connection]
<FromGitter>
<neutrinog> ok well this is annoying. I ended up with the same problem I was getting with the CrSignals lib. https://play.crystal-lang.org/#/r/8x89
<FromGitter>
<neutrinog> `Error: type must be Animal+.class, not Dog.class`
<FromGitter>
<neutrinog> even changing Animal to an abstract class doesn't work
<FromGitter>
<Blacksmoke16> whats the usecase for giving a class arg/
<FromGitter>
<neutrinog> I'm porting an entity component system library to crystal and it uses the types to filter differnents things.
<FromGitter>
<neutrinog> e.g. give me all Animal entities.. etc.
<jhass>
maybe actually removing the prefix in the names since it's redundant when you access it like LibSecp256k1::CONTEXT_VERIFY
<FromGitter>
<kingsleyh> jhass and what would my ldflags look like? would I have to compile that bitcoin lib first to creaate all the *.o files - and then do something like this: `@[Link(ldflags: "`printf %s '#{__DIR__}/../bitcoin_lib/*.o'`")]`
<FromGitter>
<kingsleyh> that didn't print very well lol
<FromGitter>
<straight-shoota> @watzon Base62 uses only alphanumericals, exactly *all* of them. Base64 aligns nicer but you need two characters in the target alphabet that are not ASCII alphanumeric.
<FromGitter>
<straight-shoota> So it's easy to use in URLs or other places where other characters might need to be escaped