<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>
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.
<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....
<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>
<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> 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> 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
<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> 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