ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | 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
<FromGitter> <Blacksmoke16> i mainly use granite since its the only one (afaik) that allows you to define annotations on the columns
<FromGitter> <Blacksmoke16> like for validations or serialization etc
<FromGitter> <didactic-drunk> Is this a known compiler bug? ⏎ Crystal 0.32.0-dev ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc8a6d5091dd14a0e997bcd]
Human_G33k has quit [Read error: Connection reset by peer]
HumanG33k has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> `squeeze` METHOD = :D :D :D :D
<FromGitter> <ImAHopelessDev_gitlab> `strip` and `squeeze` 😆
sz0 has quit [Quit: Connection closed for inactivity]
top_roupi has quit [Remote host closed the connection]
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
return0e has quit [Ping timeout: 276 seconds]
return0e has joined #crystal-lang
yukai has quit [Quit: WeeChat 1.6]
ht_ has joined #crystal-lang
<FromGitter> <watzon> @ImAHopelessDev_gitlab how goes that game btw?
<FromGitter> <watzon> Just answered your question on the forum as well
ht_ has quit [Quit: ht_]
_whitelogger has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
sagax has quit [Quit: Konversation terminated!]
sagax has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 265 seconds]
alexherbo2 has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
_whitelogger has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
return0__ has joined #crystal-lang
return0e has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
DTZUZO has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
alexherbo2 has joined #crystal-lang
<FromGitter> <sam0x17> omg, never realized `self.class.new`, slick!
<FromGitter> <tenebrousedge> @ImAHopelessDev_gitlab why are your items tuples?
DTZUZO has quit [Ping timeout: 268 seconds]
duane has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
<FromGitter> <JohnDowson> `class Test ⏎ def self.call ⏎ ⏎ ```p "hello"``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5dc971a3ca778c1fbfe3aa93]
<FromGitter> <tenebrousedge> classes aren't methods, so I don't think there's a way for the first one to work, even in RUby
<repo> hey
<repo> any ideas what's happening here? https://p.jokke.space/A51tPV/
<repo> i tried already removing ~/.cache/crystal
<FromGitter> <Blacksmoke16> https://www.php.net/manual/en/language.oop5.magic.php#object.invoke is similar to this @tenebrousedge
<FromGitter> <JohnDowson> @tenebrousedge both work in ruby. Classes are objects and () just sends :call on the object.
<FromGitter> <tenebrousedge> ew. Also, overriding `call` in Ruby is usually a bad idea
<FromGitter> <JohnDowson> Is it really overriding if there isn't a single class in the standard library that has `call` defined?
<FromGitter> <JohnDowson> *that i know of, at least
<FromGitter> <Blacksmoke16> there are some
<FromGitter> <Blacksmoke16> mainly for the `HTTP::Handler` stuff
<FromGitter> <tenebrousedge> and `Proc`
<FromGitter> <tenebrousedge> but I'm confusing it with `send` anyway
<FromGitter> <j8r> repo: it looks like a library may be missing
<FromGitter> <j8r> Are you linking statically?
<repo> no
<FromGitter> <j8r> I see an error related to `libxclib`
<repo> how come?
<repo> oh yeah
<repo> ah
<repo> yeah and that's actually a static lib
<FromGitter> <j8r> And in the LDFLAGS, there is `-Bstatic -lxclib`
<repo> yeah. must be
<repo> maybe i just have to rebuild the lib
<FromGitter> <j8r> or there is a library missing, referenced in the `.a`
<FromGitter> <j8r> which may be present, but no compiled properly
<repo> hmmm
<repo> yeah removing lib and building didn't help
<repo> it rebuilt the static lib (it's a rust extension)
<repo> but linking still fails
duane has quit [Ping timeout: 265 seconds]
duane has joined #crystal-lang
<Yxhuvud> What do the -Bstatic flag do?
<Yxhuvud> asking cause I'm trying to link to a c-lib with a bunch of functions defined as `static inline` which the linker doesn't seem to find. Perhaps it could be related to my problem :D
<FromGitter> <asterite> I don't think you can link that function, not sure
<FromGitter> <asterite> Oh, that's objective-c, but still, I'm not sure those are exported
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
<hightower3> sync
<hightower3> git diff
<Yxhuvud> I think it works the same in C, with the difference that it can then be linked (but if I understand it correctly, created and potentially inlined in each place that include the .h file).
<Yxhuvud> which mean that I may need to recreate all of those (as well as all macros) in crystal o_O
<hightower3> You could remove "inline" ;-)
<Yxhuvud> or create a wrapper C file that exposes them in a way I can use, withot inlining it.
<Yxhuvud> I think it is the static part that is problematic.
<hightower3> sync
<Yxhuvud> But it is tedious to test as there is a whole family of functions that needs to be changed then.
<Yxhuvud> ( for reference, I'm experimenting with creating bindings for https://github.com/axboe/liburing )
<repo> Yxhuvud: static functions in c are resolved only in the file they're defined in
<Yxhuvud> repo: which for .h-files is every file that include them, no?
<repo> and inline will inline them, so when the compiler is done the function is gone, inlined in the places it's used at
<Yxhuvud> which make it a bit hard to link against :/
<repo> you have static inline definitions in header files?
<repo> that's odd
<Yxhuvud> the compiler may choose to still not inline it, so that part doesn't really matter I thinik.
<Yxhuvud> Written by *much* better C programmers than I :)
<repo> hm interesting. but might be neccessary to forward declare stuff
<repo> the .h file is probably included in the corresponding .c file
<repo> -Bstatic isn't related to your problem though
<repo> -Bstatic just links the following stuff statically
<Yxhuvud> I'm thinking I'll write a C file that I can link with properly, and include the header from there, for the stuff that isn't available without actually using a C compiler.
<repo> yeah that makes sense
<repo> maybe you can generate it even :)
<Yxhuvud> though I think I'll look at the rust bindings first and see if I can understand how they do it (if they actally use the lib and not roll their own from scratch. strange bunch, the rustaceans)
<repo> :)
<repo> i bet with a lot of magic :)
ua_ has quit [Ping timeout: 240 seconds]
ua has joined #crystal-lang
ht_ has joined #crystal-lang
return0e has joined #crystal-lang
return0__ has quit [Ping timeout: 240 seconds]
dwdv has joined #crystal-lang
<dwdv> Why is `Range` defining a `cycle` func when it's mixing in another one from `Iterable` that does the very same?
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<hightower3> Hey so, if I have macro(cls), and then I create the class by doing "class {{cls}}" etc., how can I convert 'cls' then into the actual class?
<hightower3> so that I can call e.g. .name, .methods etc on it
<FromGitter> <kinxer> I think you might have to re-open it.
<FromGitter> <kinxer> I'm not sure, though.
<hightower3> I might browse among Object.subclasses maybe
<FromGitter> <Blacksmoke16> got an example?
<hightower3> Blacksmoke16 will have it.. basically what I am trying to do is convert your code of {% for e in Event.subclasses %} into code that runs immediately when I call macro event() to create an event. So in a macro event(e, *args), I need to get from "e" being first arg, to "e' being a class.
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 240 seconds]
<hightower3> One thing I see that when I "create" the class with that "class {{e}} < Parent; end", then if immediately after I browse Parent.subclasses, this one is not there as it hasn't been created yet....
sagax has quit [Read error: Connection reset by peer]
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> try like
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/7zy8
<FromGitter> <Blacksmoke16> macro finish has it wait until all types are resolved
<FromGitter> <Blacksmoke16> `finished is invoked after instance variable types for all classes are known.`
<hightower3> aah wonderful, I didn't realize that was the use... thanks!
<hightower3> hm.. in that case,...
<hightower3> in that case maybe I can wrap all the existing code in that macro and maybe I don't need to reposition the code. Will try that first, and failing that switch to this
<hightower3> (well, "all not existing code", but the "for" loop)
<FromGitter> <watzon> So two things. First of all, carc.in apparently doesn't escape HTML. Second, I guess new XML nodes that are created using `XML::Node.xpath` and similar don't actually create completely separate nodes. When using an `xpath` method on a child node it still defers to the parent. For example https://carc.in/#/r/7zyb
<FromGitter> <watzon> Anyone know how to make it so that `foo.xpath_nodes` only returns nodes that are children of foo?
sagax has joined #crystal-lang
<FromGitter> <Blacksmoke16> isnt that what its already doing?
<hightower3> success! Thanks Blacksmoke16
<FromGitter> <Blacksmoke16> np
<FromGitter> <watzon> Nope. It returns nodes anywhere in the original tree. If it were returning only children of the selected node then the output of that example would only have one element, instead it has both elements with the class `bar`
<FromGitter> <watzon> Maybe this will illustrate the issue better https://carc.in/#/r/7zym
<FromGitter> <Blacksmoke16> yea but you're printing `bar`
<FromGitter> <Blacksmoke16> not `foo`
<FromGitter> <Blacksmoke16> which there are two divs that have that class
<FromGitter> <watzon> Right, but there is only one div with the class `bar` inside of the div with the class `foo`
<FromGitter> <Blacksmoke16> ah
<FromGitter> <Blacksmoke16> sec
<FromGitter> <watzon> I know this could be solved simply in this case with a different xpath expression, but the problem is I need to get a subtree and then be able to perform xpath operations on that subtree without deferring to the parent
<FromGitter> <Blacksmoke16> get rid of the `//`
<FromGitter> <Blacksmoke16> `//` tells it to search from root
<FromGitter> <watzon> Ok but that leads to another issue, sec
<FromGitter> <watzon> It only works for direct decedents https://carc.in/#/r/7zyw
<FromGitter> <watzon> I've played with all of the prefixes, but having a reference to that original root just fucks things up
<FromGitter> <Blacksmoke16> hmm
<Yxhuvud> Seems even the rust people do wrapper c scripts. Hmm. I wonder how to organize that in the best way..
<FromGitter> <Blacksmoke16> i lied `/` is the one that does from root node, `//` `Selects nodes in the document from the current node that match the selection no matter where they are `
<FromGitter> <watzon> Ahh yeah. The "no matter where they are" is the problem. It would be nice if it just selected children of the current node.
<FromGitter> <Blacksmoke16> i think you'd have to duplicate the xpath
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc9b45b4adf071a84100f48]
<FromGitter> <Blacksmoke16> so that when it goes to find `baz` it knows to only do it on the dependents of those that have `foo`
<FromGitter> <watzon> Omg I figured it out
<FromGitter> <watzon> https://carc.in/#/r/7zzg
<FromGitter> <watzon> Apparently there's also a little known `.//`
<FromGitter> <Blacksmoke16> separate things
<FromGitter> <Blacksmoke16> `.` represents current node, so that works too :p
<FromGitter> <watzon> Finally haha. Just had to rubber duck this sucker.
<FromGitter> <Blacksmoke16> 👍
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
Human_G33k has joined #crystal-lang
alexherbo2 has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
Human_G33k has quit [Ping timeout: 268 seconds]
rocx has quit [Quit: 👏 developers 👏 developers 👏 developers 👏 developers]
<blassin> how do I convert an unsigned 16 bit int to a signed one?
<FromGitter> <tenebrousedge> `to_i16` ?
<FromGitter> <Blacksmoke16> did you try like `.to_i`?
<FromGitter> <Blacksmoke16> er what @tenebrousedge said
<blassin> `to_i16` gives me `Arithmetic overflow`
<blassin> the number is a UInt16 holding 0xffbe
<FromGitter> <tenebrousedge> do you want to wrap?
<FromGitter> <Blacksmoke16> is that bigger than what a signed 16bit number could hold?
<FromGitter> <christopherzimmerman> Int16 only goes to 32k something
<FromGitter> <christopherzimmerman> thats 64k
<blassin> I want it to do basically `s = s - 2**16 if s > (2**16 / 2)` which is what I do by hand now
<FromGitter> <christopherzimmerman> *65k something
<FromGitter> <Blacksmoke16> yea, so would have to do like `.to_i`
<FromGitter> <Blacksmoke16> so it would fit
<blassin> to_i just makes it 0xffbe as an Int32
<FromGitter> <Blacksmoke16> right
<FromGitter> <Blacksmoke16> is that not what you want?
<FromGitter> <tenebrousedge> he wants to wrap i think
<blassin> I want it to "fit" 0xffbe into the signed 16 bit space, ie subtract 2**16 from it
<blassin> I guess that's it, yeah
<FromGitter> <Blacksmoke16> `0xffbe` doesnt fit into a `Int16`
<blassin> I know that
<blassin> I want the lang to do the math for me, and give me the binary equivalent
<blassin> by subtracting 2**16 from it
<blassin> basically, I'm reading bit values
<blassin> and you can interpret 0xffbe signed or unsigned
<blassin> I want to convert it from a UInt16 to Int16 with "the same bits"
<blassin> if that makes sense
<FromGitter> <christopherzimmerman> So in this case you would want -66?
<blassin> yes
<FromGitter> <Blacksmoke16> `.to_i16!`
<FromGitter> <Blacksmoke16> wait so the wrapped value actually means something?
<FromGitter> <tenebrousedge> oh, there are bang methods for that?
ht_ has quit [Remote host closed the connection]
<blassin> that works, thanks! :D
<FromGitter> <tenebrousedge> `unsafe_as(UInt16)` works too
<blassin> couldn't find it in the docs, but I knew it had to be somewhere ;)
<FromGitter> <Blacksmoke16> but back to my question, when a value gets wrapped does the resulting value actually mean something? i never really thought about it
<FromGitter> <Blacksmoke16> always kinda assumed it was just some random value...
<FromGitter> <tenebrousedge> 👀
<blassin> I was looking in the Int docs, my bad
<blassin> BlackSmoke16: yeah, wrapping just means "cast this to signed" right?
<blassin> or "give me this value in a different number range"
<blassin> not sure what the correct technical term would be
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <christopherzimmerman> I think its called saturation.
<blassin> basically, you can read this bitstream (1111111110111110) as either 65470 or -66
<blassin> to prevent from having to cast it all the time `.as(UInt16)` I just have it always as UInt16 and the few random bits I need it signed, I convert
<blassin> *wrap
<blassin> but doing it by hand felt wrong, hence my question
<blassin> thanks again!
<FromGitter> <Blacksmoke16> hmm yea this boggles my mind a bit
<FromGitter> <Blacksmoke16> FWIW https://crystal-lang.org/api/master/BitArray.html might be helpful?
<blassin> I'm just using << and >> since they're faster
<FromGitter> <Blacksmoke16> fair enough
<blassin> I might try that sometime though, thanks
<hightower3> There we go folks - https://github.com/crystallabs/event_handler
<FromGitter> <wontruefree> this is really interesting https://github.com/crystallabs/crysterm
<hightower3> wontruefree: yes, improving by the day - event_handler is one of the spin-offs from that projects
<FromGitter> <wontruefree> I am running the examples and they do not work for me
<FromGitter> <wontruefree> but I will have to look into it more
<hightower3> yeah, the development there is very active, not polished like event_handler
<hightower3> although they should run, I will check them right now
<hightower3> Blacksmoke16 I see you were going over shards listed on awesome-crystal. If you have an idea which category event_handler should go in, please let me know. I checked and in the absence of ideal category, "Framework Components" or "Queues and Messaing" seemed closest
duane has quit [Ping timeout: 268 seconds]
<hightower3> wontruefree fixed all the examples to run without error. They are still very rough though, and except for hello.cr and gpm_client.cr (which you must run from console, not X) there isn't much to see visually.
<FromGitter> <Blacksmoke16> was thinking how i want to handle events in athena
<FromGitter> <Blacksmoke16> sec i can make an example
<FromGitter> <Daniel-Worrall> hightower: Nice, I might be integrating that into a lib soon
<FromGitter> <Daniel-Worrall> Seems to be a better API than Onyx-EDA for my uses
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo2 has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Any thoughts to move the `event` macro to a module so as not to polute the global namespace
<FromGitter> <Daniel-Worrall> Also, a suggestion to put the dependency name/link/current version stuff on readme so it's easy to grab
alexherbo27 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
<FromGitter> <Blacksmoke16> after thinking on it a while this is what i came up with (for how im approaching event listeners)
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/802p
<FromGitter> <Blacksmoke16> listeners and events get built at compile time
<FromGitter> <Blacksmoke16> uses annotation to make a method as a handler and uses the first arg to set the proc type cast
<FromGitter> <Blacksmoke16> future plan would be the annotation also has a `priority` option that controls the order in which they get executed
<FromGitter> <Blacksmoke16> defining the handlers is a bit more verbose, since you have to make a type and everything, but makes it testable and DI compatible
<FromGitter> <Blacksmoke16> main use case for this im thinking is as a replacement to `HTTP::Handler` style middleware in Athena
<FromGitter> <Blacksmoke16> would be super clean to have third party shards define a handler that just gets picked up by athena, and not have to touch anything else
<FromGitter> <Blacksmoke16> or for CORS etc
<FromGitter> <Blacksmoke16> hightower3: could always just add a new section if it doesnt fit directly into any other group
<hightower3> OK, will think about it and come up with some PR there
<hightower3> Daniel-Worrall: great, thanks for comments, will address them right now
alexherbo27 has quit [Ping timeout: 240 seconds]