ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | 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
<hightower2> yeah Ruby's method does it. The docs show only 3 examples of what it parses, but it parses a whole bunch of formats.
<hightower2> (I mean the parse() functions in Date, Time, and DateTime)
<hightower2>
<hightower2> If a C function takes 'int' argument, what type is that in LibC::* ?
<hightower2> (such as char *index(const char *s, int c))
<FromGitter> <Blacksmoke16> `LibC::Int`?
<FromGitter> <Blacksmoke16> i think thats a thing
<hightower2> Undefined constant LibC::Int
<FromGitter> <Blacksmoke16> uh
<hightower2> hm but it does exist as alias for Int32 in crystal/src/lib_c.cr
<FromGitter> <Blacksmoke16> right
<hightower2> I must be missing something
<hightower2> specifying it as ::LibC::Int works, LibC::Int doesn't, at least in my case
<FromGitter> <Blacksmoke16> are you doing something within `LibC` diretory?
<FromGitter> <Blacksmoke16> er namespace
<hightower2> ah yes.. no I do this from inside LibC, but it must be that default type has priority
<hightower2> er Crystal type
<FromGitter> <Blacksmoke16> yea, without the `::` its looking in your namespace for it
<hightower2> yeah
<FromGitter> <watzon> Well here we go, still early days, but I've got a kind of nice wrapper around LibUI that abstracts away all the C stuff https://github.com/watzon/cru
<FromGitter> <watzon> I was thinking lubui was dead, but the project has seen some activity recently and the maintainer posted a notice on the readme
<hightower2> mm interesting that it chose gtk instead of Qt
<FromGitter> <watzon> Makes sense. Qt licensing is a mess.
<FromGitter> <watzon> @oprypin good work on getting Crystal working in Windows!
darkstar_13 has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 246 seconds]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <Blacksmoke16> @paulcsmith ⏎ ⏎ > But I can’t do what I would prefer witht he current implementation. I have to monkey patch all kinds of things on Log
<FromGitter> <Blacksmoke16> why not just use the `Log` module's features as they are?
<FromGitter> <Blacksmoke16> you still get structured data, and can now control the order of that context in relation to the message
<FromGitter> <Blacksmoke16> you're fighting against the implementation
ur5us has joined #crystal-lang
<FromGitter> <watzon> Ok apparently I still don't completely understand Crystal's event loop
<FromGitter> <watzon> https://hasteb.in/acinubog.rb
<FromGitter> <watzon> Line 48. Is there anyway to do something like what I'm trying to do without running the bot itself as another process?
<FromGitter> <watzon> If I just run the bot with `@bot.poll` it locks the event loop, so the GUI freezes. I thought I could launch the bot in a fiber, but the fiber just exits unless I use a sleep, and then it exits immediately after the sleep.
<FromGitter> <paulcsmith> @Blacksmoke16 I’ve written many examples of how it won’t work for me. Most of our logs do not have a string message.
<FromGitter> <paulcsmith> And yes I’m fighting against the implementation, but I do not think that that means it can’t or shouldn’t be changed
<FromGitter> <paulcsmith> For example I could say you are trying to render json and since log context doesn’t support that you are going against the implementation. But that doesn’t make sense as an argument because implementations can change
<FromGitter> <Blacksmoke16> i dunno, it just seems like a lot more work to try and refactor the whole Log module so you dont have to give a string message, and just give a string message and call it a day?
<FromGitter> <Blacksmoke16> rendering the context as json doesnt require a refactor of how context is handled
<FromGitter> <paulcsmith> The new log itself is a refactor. The changes I propose are incredibly simple. This isn’t some massive change. As shown in the examples you can still use it as you can today and pass a message string. So there is no downside but it allows a lot more flexibility for other use cases
<FromGitter> <Blacksmoke16> right, and now it has a way to handle extra data
<FromGitter> <Blacksmoke16> before it didnt, and what you're doing made more sense then
<FromGitter> <paulcsmith> Also I’ve shown examples where a message doesn’t make sense. Could you show how you would do it? For example if I want to log the query and the query args what would the message be on top of the query and args data?
<FromGitter> <paulcsmith> So here’s the thing I’m getting frustrated by. I’m not telling you your way is wrong or shouldn’t be done but you seem to be telling me mine is
DTZUZU2 has joined #crystal-lang
<FromGitter> <paulcsmith> That’s frustrating. Especially as I have given many examples of why I want to do things. It is a huge bummer and makes me not want to offer suggestions
<FromGitter> <Blacksmoke16> `Log.info(query: @query, args: logging_args) { "Querying for #{self.class} }`
<FromGitter> <paulcsmith> Except we don’t know the class
<FromGitter> <paulcsmith> That’s my point
<FromGitter> <Blacksmoke16> in that case `Executing query`
<FromGitter> <Blacksmoke16> and call it a day
DTZUZU has quit [Ping timeout: 256 seconds]
<FromGitter> <Blacksmoke16> I'm only one person, maybe others have different opinions. However yes I think what you're doing isnt ideal. context is there for this reason
<FromGitter> <paulcsmith> Imo that is superfluous. We have different opinions. But why should we not allow for more options if the api remains almost identical?
<FromGitter> <paulcsmith> This is what I don’t get. It seems like you want to impose your way of doing things and I don’t get that. Are you so sure your way is better and what I’d like to do is not worth trying to do?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <paulcsmith> Wow
<FromGitter> <Blacksmoke16> because its not as simple as you think, `entry.message` i get the message, `entry.context` i get the context, i dont want to do `entry.context[:message]`
<FromGitter> <Blacksmoke16> or have a getter that does that
<FromGitter> <paulcsmith> I’ll just stop conversing ;) there is nothing else to do if you think my way is just dumb and shouldn’t be done 🤷‍♂️
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> again this is only my opinion, we'll see what others think
<FromGitter> <Blacksmoke16> maybe ill be proved wrong 😉
<FromGitter> <watzon> Until then... if anyone gets a chance :) https://gitter.im/crystal-lang/crystal?at=5e990fe885b01628f0549615
<FromGitter> <watzon> Lol
<FromGitter> <Blacksmoke16> @watzon makes sense, have you tried MT mode?
<FromGitter> <Blacksmoke16> because currently if the main thread doesnt block that other fiber woudnt have a chance to execute
<FromGitter> <watzon> I tried using the flag, but Crystal said it doesn't exist
<FromGitter> <Blacksmoke16> `-Dpreview_mt`?
<FromGitter> <watzon> Nvm I was a being a dumbass
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <watzon> Haha well it works
<FromGitter> <Blacksmoke16> nice
<FromGitter> <watzon> > because currently if the main thread doesnt block that other fiber woudnt have a chance to execute ⏎ The funny thing is, the main thread should be blocking. But then again, it's a C library doing the blocking, so I don't think Crystal knows
<FromGitter> <watzon> I guess I could fake a block by using sleep, maybe that would work
<FromGitter> <Blacksmoke16> @paulcsmith and sorry if i was coming across as a dick. You're entitled to your opinion and idea, but to me your just trying to implement something that is already possible in a different way. When you could just do what you want now with the current feature set of `Log`. I.e. `Log.info(query: @query, args: logging_args) { }`
<FromGitter> <Blacksmoke16> and tada everything works as you want
<FromGitter> <watzon> Actually no, I'd have the same issue
<FromGitter> <watzon> Nvm haha
Human_G33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Max SendQ exceeded]
<FromGitter> <paulcsmith> @Blacksmoke16 except the message is empty and so it would be printed as “message: null” in js for example. I could strip that out (which is what I’m doing) but I’d prefer not to
<FromGitter> <paulcsmith> It’s all good though. I can tell my proposal is not liked so I will let it be
<FromGitter> <Blacksmoke16> no, its not liked by 1 person, there are many more people with opinions than just me :)
<FromGitter> <Blacksmoke16> you're formatter could just ignore it
<FromGitter> <Blacksmoke16> ```unless entry.message.empty? ⏎ io << ' ' << entry.message ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e9914c7d65bcf75b5c883d8]
<FromGitter> <Blacksmoke16> your*
<FromGitter> <Blacksmoke16> ah nvm, i missed the last part
<FromGitter> <Blacksmoke16> small price to pay versus monkey patching everything tho :shrug:
<FromGitter> <paulcsmith> There’s a bit more to it than that. Like wanting to put message context data first, and filtering out context data in some formatters but I get it is pretty niche! So I’m fine if it changes
<FromGitter> <Blacksmoke16> but you can do that already? since the message is separate from the context, or iterate over key/values of the context and skip stuff
<FromGitter> <Blacksmoke16> ```entry.context.each do |k, v| ⏎ # Write to IO ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e991756c7dcfc14e2c45dce]
<FromGitter> <Blacksmoke16> that should be a thing if its not already...
<FromGitter> <Blacksmoke16> ogh, you cant
<FromGitter> <Blacksmoke16> `entry.context.as_h.each do` there we go
<FromGitter> <paulcsmith> Yeah and because if I leave the message blank and the log data is in the context then I can’t determine what is “context” and what is the log data
<FromGitter> <Blacksmoke16> the log data would be the context?
<FromGitter> <paulcsmith> But I’ve got a pretty simple backwards compatible monkey that should work great for my needs
<FromGitter> <Blacksmoke16> like to be clear ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5e991ce15706b414e1d1c2fc]
<FromGitter> <paulcsmith> Meaning Log.info(query: query) {}
<FromGitter> <paulcsmith> No way to tell that query is really the log data and separate from what is normally consider “global” context
<FromGitter> <paulcsmith> So no way to just get the context for that single entry
<FromGitter> <Blacksmoke16> ```code paste, see link``` ⏎ ⏎ To be clear this is what I've been talking about [https://gitter.im/crystal-lang/crystal?at=5e991d418e987f3a5e202a27]
<FromGitter> <Blacksmoke16> if you dont use `with_context`, then its added to all entries logged after the context was set
<FromGitter> <Blacksmoke16> otherwise is specific to the entries logged within the block
<FromGitter> <tenebrousedge> was that supposed to be `Log.with_context do` and if so, why is the block not passed an argument?
<FromGitter> <Blacksmoke16> sorry yea, my bad
<FromGitter> <Blacksmoke16> he doesnt want a message and it requires a block so :shrug:
<FromGitter> <tenebrousedge> `Log.with_context do |context|` sounds like a thing
<FromGitter> <paulcsmith> Yeah that makes sense and is what I’m doing now with Dexter but it isn’t quite good enough because I can’t tell what was global and what was for just that one entry. So for the pretty formatter I have to print it all *and* the local context comes first. But I’d prefer the log specific context to come first as it is the most important part
<FromGitter> <Blacksmoke16> naw its not https://crystal-lang.org/api/master/Log.html#with_context(&)-class-method
<FromGitter> <tenebrousedge> that seems silly
<FromGitter> <paulcsmith> And I can’t reverse it because sometime the log data wouldn’t make sense. For example I would want the query args to be printed before the query
<FromGitter> <Blacksmoke16> logger we use at works has 2 "context" objects because of this
<FromGitter> <Blacksmoke16> extra and context to be able to tell the two appart
<FromGitter> <Blacksmoke16> but you could have the context be some other construct
<FromGitter> <paulcsmith> Exactly. That’s what I’m proposing. A message data context and the the global fiber context
<FromGitter> <paulcsmith> And then also add message to the message data but I know that’s probably not gonna happen
<FromGitter> <Blacksmoke16> can already be done tho, `Log.context.set local: {entry: entry}`, something like that, then can check if `local` is defined and set
<FromGitter> <Blacksmoke16> if so print those then do normal `context`
<FromGitter> <paulcsmith> Ahhh that is an interesting idea.
<FromGitter> <Blacksmoke16> could abstract it to like `def set_local(**args)`
<FromGitter> <Blacksmoke16> either way you're going to end up with long lines if you have a lot of data
<FromGitter> <paulcsmith> I still will need to monkey patch the log methods to allow returning a named tuple in the block. I want to keep the performance high because I plan to add a fair amount of logging and sometimes the calculations can add up
<FromGitter> <Blacksmoke16> i would doubt the order would matter
<FromGitter> <Blacksmoke16> do the proc thing
<FromGitter> <paulcsmith> Not sure I understand. What Proc thing?
<FromGitter> <Blacksmoke16> someone didnt read my entire reply :(
<FromGitter> <Blacksmoke16> :p
<FromGitter> <Blacksmoke16> > You got me there. However I don’t think its that big of a deal. Most of the time the context would be data you already have available. Plus if you really needed you (or the stdlib) could define an overload like ⏎ def self.info(ctx : Proc(Log::Context, ...) which would only be called when it is going to set the context, i.e. if the entry is going to be logged.
<FromGitter> <Blacksmoke16> overload that accepts a proc of context
<FromGitter> <Blacksmoke16> dunno how clean you could get it but :shrug:
<FromGitter> <paulcsmith> Ohh I get what you mean. I thought you were talking about the formatter from above
<FromGitter> <Blacksmoke16> or
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e99205ac38aa05a1a7ad1db]
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e9920bee920022432adf245]
<FromGitter> <Blacksmoke16> no idea if that would work tho
<FromGitter> <Blacksmoke16> er `return unless @level <= Log::Info`
<FromGitter> <Blacksmoke16> ah nvm
<FromGitter> <paulcsmith> It’s all good. I think the Proc overload might work
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e99232d2ff88975b4266c7a]
<FromGitter> <Blacksmoke16> or maybe ⏎ ⏎ ```if logger.handles? :debug``` [https://gitter.im/crystal-lang/crystal?at=5e992349a412254f218e81ea]
<FromGitter> <Blacksmoke16> dont like how you have to give the severity twice, but :shrug:
<FromGitter> <Blacksmoke16> bit cleaner than the proc would be at least
<FromGitter> <Blacksmoke16> `logger.debug { "MESSAGE"}, { context }`, multiple blocks when 😆
renich has quit [Ping timeout: 256 seconds]
renich has joined #crystal-lang
<FromGitter> <Blacksmoke16> heres a question, method that returns true/false if a given `Log` instance is able to handle a given `severity`/
<FromGitter> <Blacksmoke16> `.loggable? :info`, `.supports? :info`, `.handles? :info`?
<FromGitter> <Blacksmoke16> `.allows? :info`, etc?
darkstar_13 has joined #crystal-lang
olbat[m] has quit [*.net *.split]
flips has quit [*.net *.split]
asterite has quit [*.net *.split]
oprypin has quit [*.net *.split]
FromGitter has quit [*.net *.split]
twistedpixels has quit [*.net *.split]
jhass has quit [*.net *.split]
flips has joined #crystal-lang
jhass has joined #crystal-lang
twistedpixels has joined #crystal-lang
oprypin has joined #crystal-lang
asterite has joined #crystal-lang
olbat[m] has joined #crystal-lang
FromGitter has joined #crystal-lang
ur5us has quit [Ping timeout: 272 seconds]
_ht has joined #crystal-lang
alexherbo2 has joined #crystal-lang
renich has quit [Quit: renich]
<FromGitter> <confact> Found a bug I think, but not sure if it should actually act like that: ⏎ I get this on `crystal doc`: ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5e9958ee8e987f3a5e2112ab]
darkstar_13 has quit [Quit: Leaving]
darkstar_13 has joined #crystal-lang
darkstar_13 has quit [Remote host closed the connection]
darkstardevx has joined #crystal-lang
darkstardevx has quit [Read error: Connection reset by peer]
chachasmooth_ has joined #crystal-lang
chachasmooth has quit [Ping timeout: 272 seconds]
darkstardevx has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#9b12792 (master - XML: Use Fiber level Mutex instead of Thread::Mutex (#9098)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/676133189
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 250 seconds]
alexherbo20 is now known as alexherbo2
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#95037fe (master - Use correct command for running a particular spec (#9103)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/676150155
Welog has quit [Remote host closed the connection]
<FromGitter> <ImAHopelessDev_gitlab> this travis-ci bot makes me want to jump off a bridge while compiling a 200k loc crystal project
<FromGitter> <ImAHopelessDev_gitlab> damn it's already Friday, LOL
<FromGitter> <ImAHopelessDev_gitlab> good morning!!!
<FromGitter> <Blacksmoke16> o/
<FromGitter> <stronny> \o
<FromGitter> <pynixwang> how compiler deals with multi callback macros like `included`, override? all of them? and what order.
<FromGitter> <pynixwang> ```crystal x.cr ⏎ 1 ⏎ 2``` [https://gitter.im/crystal-lang/crystal?at=5e99b85ac38aa05a1a7d4ede]
<FromGitter> <pynixwang> all of them
<FromGitter> <pynixwang> require order?
<FromGitter> <ImAHopelessDev_gitlab> not sure pynix, might need lead dev to take a stab at ur question
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#c470786 (ci/fix-nightly - Move recent additions to DIBuilder to LLVMExt): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/676280804
travis-ci has left #crystal-lang [#crystal-lang]
zorp_ has joined #crystal-lang
zorp has quit [Ping timeout: 256 seconds]
<FromGitter> <watzon> What I want to know @oprypin is how you'd handle a C closure with something like this https://github.com/andlabs/libui/blob/master/ui.h#L308
<FromGitter> <watzon> Those function pointers don't accept a `data` variable
rw has joined #crystal-lang
rw has quit [Remote host closed the connection]
<oprypin> watzon, uh could you give some more context
<oprypin> btw is this ui.h the entire api?
<oprypin> does this have documentation or what
<oprypin> watzon, btw it would be so weird to create an entire new uiAreaHandler with all of those function pointers (also newly created functions) and each of which would have a closure associated
<oprypin> i think you create one uiAreaHandler globally
<oprypin> and determine by the passed `uiArea *` which object we're looking at
<oprypin> like this should be `class UIArea; @@handler = uiAreaHandler.new(->global_function1, ->global_function2); @uiarea : Pointer(uiArea);`
<FromGitter> <watzon> Well a `uiAreaHandler` is the low level struct for creating a widget basically. So each custom widget is going to need to create a `uiAreaHandler` which then gets converted into a `uiControl` with `uiNewArea(handler)`
<oprypin> and `def global_function1(unused_handler, uiarea, drawparams); (uiarea - 4).as(UIArea*).value.actual_draw_handler; end`
<FromGitter> <watzon> The API is still fairly alpha, so good docs don't exist yet
<oprypin> why bother with this
<FromGitter> <watzon> Even though it's alpha, it's still a pretty decent cross platform UI framework
<FromGitter> <watzon> And I plan on keeping up with its development
<oprypin> watzon, i disagree with >each custom widget is going to need to create a `uiAreaHandler`
<oprypin> uiNewArea *really* should let you pass data, thats just not good
Welog has joined #crystal-lang
<FromGitter> <watzon> Here's an example of it actually being used https://github.com/andlabs/libui/blob/master/examples/histogram/main.c#L255
<FromGitter> <watzon> But I agree. Maybe I'll file an issue.
<oprypin> watzon, to not be wasteful your goal should be to use one global uiAreaHandler
<FromGitter> <watzon> Would that not cause issues if it's reused?
<oprypin> watzon, lets forget about crystal for a sec
<oprypin> u could write 1 global handler in C that goes like `if (uiarea == myuiarea1) do_this; else do_that`
<oprypin> now imagine that C has classes. you could say `myuiarea1.myhandler = do_this; myuiarea2.handler = do_that` and your actual handler you pass to would just be `uiarea.handler()` - the exact same for every uiarea
<oprypin> i know i'm explaining horribly but are u still with me 😂
<FromGitter> <watzon> Not completely, but I think I mostly get what you're saying
<oprypin> watzon, ok so now switch back to crystal. it *actually has* classes. and you can just save any closure that you like inside your object
<oprypin> but the problem is that your object in crystal only *contains* a pointer to an uiarea, rather than *actually being equal* to it
<FromGitter> <watzon> Right
<oprypin> now you just need a way to go back from that pointer that it passes to you , to the actual crystal object
<oprypin> which can be done with various hacks actually, like a hashtable of weak pointers or somethin
<FromGitter> <watzon> Oof this sounds like a massive pain haha
<oprypin> but if it let you pass through a pointer to your own crystal object as data*, then you'd just get that object
<oprypin> in crsfml i used to do this shit by embedding the object one into another and doing pointer math but i abandoned that later
<FromGitter> <watzon> I know this is terrible right now, but my original idea was to do something like this https://hasteb.in/yomasogu.rb
<FromGitter> <watzon> But it's sounding like that's just not going to work
<oprypin> well no that's *exactly* what you want
<oprypin> and i'm showing you the only path to achieving that
<oprypin> actually not exactly
<oprypin> it would be `abstract class Area`, without the handler part
<oprypin> and `abstract def on_draw(` would not accept an art
<oprypin> arg
<oprypin> i'm passing `self.as(Void*)` to C++ code and then it gives that back to me in the callback, and i convert it back
<FromGitter> <watzon> Hmm I see
commavir has quit [Remote host closed the connection]
<oprypin> so @watzon *that* is how you'd use `data` and one global callback
commavir has joined #crystal-lang
<FromGitter> <watzon> *But* it's not going to be possible that way unless they modify the API so `uiNewArea` takes a `data` parameter
<oprypin> yes
<FromGitter> <watzon> Crap
<FromGitter> <watzon> Guess I need to make an issue
<oprypin> watzon, i can show u another way, i just realized
<FromGitter> <watzon> Oh?
<oprypin> watzon, you know how the struct's member layout is part of the API https://github.com/andlabs/libui/blob/a0a980712e8057d86747fcf52b67f59b56932f5a/ui.h#L308
<oprypin> but if you append another field to it, they won't be able to tell.
<oprypin> in crystal `lib` `struct uiAreaHandler` you just add your own field `data : Void*`
<FromGitter> <watzon> Oooh
<FromGitter> <watzon> I didn't know that was possible
<oprypin> that's the basics of how class inheritance works in C 😂
<oprypin> i first learned it from libchipmunk, it's awesome
<oprypin> watzon, anyway, so in your callback you get a pointer to this uiAreaHandler. so in crystal code you just go handler.data.as(Area*).value.my_abstract_def(foo)
<oprypin> but now, although the actual functions will be global, you'll still need to make an uiAreaHandler every time yourself, pointing to the exact same 5 functions but differing by the data member
<FromGitter> <randiaz95> Hi guys..
<FromGitter> <randiaz95> Does any1 know how to copy and paste from main machine to virtual machine?
<FromGitter> <randiaz95> in vbox?
<oprypin> randiaz95, u can enable guest additions and then in top menu bar enable two way dragdrop
<oprypin> but better add a shared folder
<FromGitter> <stronny> don't use the console window
<FromGitter> <stronny> use putty/kitty
<FromGitter> <stronny> actually who's the host and who's the guest?
<oprypin> watzon, in case you're still not tired of me, here's proper C inheritance. they actually use composition but then use pointers to the base class interchangeably with the subclass. the important part is that you allocate enough memory for the *sub*class first even if you use it as the base class.
<FromGitter> <watzon> @oprypin so you more or less mean something like this, right? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ on the right track? [https://gitter.im/crystal-lang/crystal?at=5e99f57a47110862053bd7e1]
<FromGitter> <watzon> So I end up with global callbacks, but each instance of `Area` has its own handler
<oprypin> watzon, yea looks perfect
<oprypin> dont forget `handler.data = `
<oprypin> dont forget `handler.data = self.as(Void*)`
<FromGitter> <watzon> Right, forgot to add it before asking
<oprypin> now i just hope that this doesn't cause an unresolvable circular reference for the garbage collector
<oprypin> watzon, you probably actually need to store the handler. `@handler = `
<FromGitter> <watzon> Yeah true
<FromGitter> <watzon> Will that not cause issues with `self`?
<oprypin> uhhh
<FromGitter> <watzon> If I reference self before I'm finished defining instance vars
<FromGitter> <watzon> I guess @handler is already defined
<oprypin> @watzon, just move `handler.data=` to the last line of initialize and should be good
<FromGitter> <watzon> Yeah true
<FromGitter> <stronny> I think `self` does exist in initialize
<FromGitter> <watzon> It does, you just have to have defined instance variables before referencing it
<FromGitter> <watzon> So I couldn't do `@somevar = SomeClass.new(self)`
<FromGitter> <watzon> But I could do `@somevar = SomeClass.new; @somevar.client = self`
<FromGitter> <watzon> As long as I do the latter part *after* all instance variables are finished being defined
<FromGitter> <stronny> riiight, didn't see it before
<FromGitter> <randiaz95> Thanks guys!@
<FromGitter> <randiaz95> Sorry i had to run to the restroom lol
<FromGitter> <watzon> This seems to compile at least @oprypin https://hasteb.in/corisonu.rb
<FromGitter> <watzon> Gotta actually finish the other callbacks and test now, but thanks!
<oprypin> watzon, that's nice! you can drop the argument `area : UI::Area*` from abstract def
<oprypin> that'll just be `self`
<FromGitter> <watzon> Ahh that's true
<FromGitter> <watzon> Thanks for the help though, I never would've figured this out on my own
<oprypin> :>
<FromGitter> <randiaz95> is it best practice to pass a callback or pass a function within a class/function in general?
<FromGitter> <randiaz95> for reusability?\
<FromGitter> <stronny> what?
<FromGitter> <stronny> best practice is to use blocks
<FromGitter> <randiaz95> Where is the best resource to use blocks?
<FromGitter> <stronny> resource?
<FromGitter> <randiaz95> I haven't reached blocks in: https://crystal-lang.org/reference/syntax_and_semantics/blocks_and_procs.html yet
<FromGitter> <randiaz95> I think i could learn it there.
zorp_ has quit [Ping timeout: 256 seconds]
<FromGitter> <randiaz95> Im still at generics
<FromGitter> <tenebrousedge> what's the actual problem you're working with, that provoked this question?
<FromGitter> <randiaz95> I was trying to make a function that wraps around the permutation method
<FromGitter> <randiaz95> so that I could get random permutations of the alphabet to generate possible url links
<FromGitter> <tenebrousedge> maybe an iterator would be useful there
<FromGitter> <randiaz95> aaa.com aab.com aac.com
<FromGitter> <randiaz95> etc
<FromGitter> <stronny> do you have ruby experience?
<FromGitter> <randiaz95> very little ruby experience
<FromGitter> <watzon> The final @oprypin if you have any more comments https://hasteb.in/afejefil.rb
<FromGitter> <watzon> Turned out easier, albeit hackier, than I could've hoped haha
<FromGitter> <randiaz95> Maybe I want to do 3 letters and maybe I want to do 10 letters ( Which would be 10 factorial )
<FromGitter> <randiaz95> Im just going to write it in python for now and send it to a .txt and then read it in crystal with File.read("urls.txt").split("\n")
<FromGitter> <watzon> Better https://hasteb.in/zanuxezi.rb
<FromGitter> <tenebrousedge> @randiaz95 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e99fca1d240da24337d300d]
<FromGitter> <randiaz95> Ooo
<FromGitter> <randiaz95> i need to look into that sample method.
<FromGitter> <randiaz95> it would obviously create duplicates given a long enough time horizon right?
<FromGitter> <tenebrousedge> yes
<oprypin> watzon, yea good. needs `lib` for completeness
<FromGitter> <watzon> I also just figured out that the `LibC::Int` in `on_mouse_crossed` is actually just a bool
<FromGitter> <watzon> Just a 1 or 0
<FromGitter> <randiaz95> Hey Thanks Kai! I think I figured it out
<FromGitter> <tenebrousedge> 👍
<FromGitter> <randiaz95> I can keep a static attribute that has previous values and just call next
<FromGitter> <randiaz95> if exists then just next again
<FromGitter> <randiaz95> not performant; but this is just for fun lol
<FromGitter> <tenebrousedge> if you're not generating tons of them that's not a bad way to go
<FromGitter> <randiaz95> the randomness actually adds value to what I am doing.
<FromGitter> <randiaz95> due to the fact that websites most likely dont have common letters one after another
<FromGitter> <tenebrousedge> probably. Use a hash for your previously generated attribute
alexherbo23 has joined #crystal-lang
<FromGitter> <randiaz95> ^^ true.. lookup time would be faster
<FromGitter> <randiaz95> and i can have a keystore of date
<FromGitter> <randiaz95> for previously requested data
<FromGitter> <randiaz95> if it's been a month i can lookup again.
<FromGitter> <tenebrousedge> hmm, kay
<FromGitter> <randiaz95> controversially scanning the internet for sentiment of websites lol
<FromGitter> <randiaz95> hope I don't hit any porn sites.
alexherbo2 has quit [Ping timeout: 256 seconds]
<FromGitter> <watzon> Lol
alexherbo23 is now known as alexherbo2
<FromGitter> <randiaz95> though I am interested in their sentiment
<FromGitter> <randiaz95> If anyone is interesting in playing with NLP I am daddling with https://github.com/cadmiumcr/cadmium
<FromGitter> <kinxer> Iirc, that's one of @watzon's.
<FromGitter> <randiaz95> I wonder if it uses bayesian conditional probabilities
<FromGitter> <randiaz95> it's training data uses values above 1 and below -1 and includes emojis :D
<FromGitter> <randiaz95> Very clean code I must say..
<FromGitter> <watzon> That is indeed
<FromGitter> <watzon> And thank you :)
<FromGitter> <randiaz95> Watson do you want me to give you a data set for spanish?
<FromGitter> <watzon> That would be cool, I'll have to modify the API to work with multiple languages
<FromGitter> <randiaz95> I have virtually no bandwidth; and I am sure you don't have time either, but if I don't put it up in my github and send you the link I will forget.
<FromGitter> <randiaz95> <- needs vacation lol
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#26ec084 (master - Add Log::IOBackend#new with formatter (#9105)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/676348417
<FromGitter> <watzon> Yeah sounds great man
<FromGitter> <randiaz95> Ok @watzon https://github.com/randiaz95/spanish is the link essentially how I did it before was create a file for *negative words under the filename of badLexStem.txt and *positive words under the name goodLexStem.txt
<FromGitter> <randiaz95> i put +1 for good and 0 for bad in my model
<FromGitter> <watzon> Heck if you want to you can make a PR and just add the file in this folder (https://github.com/cadmiumcr/sentiment/tree/master/src/cadmium/sentiment/data) under `sentiment_es.txt`.
<FromGitter> <randiaz95> ok, I will preprocess and make that file is 1 positive and -1 negative good under the tab delimited file structure?
<FromGitter> <randiaz95> The really valuable file is the synonym one dictConjug.json
<FromGitter> <watzon> Sounds good man
zorp_ has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter> <randiaz95> @watzon I am learning NLP stuff with my new job; so I will probably ask questions about your repo to learn more!
<wmoxam> ha, I upgraded from an i3-6100 -> Ryzen 3600 and my Crystal project test suite run time went from 7.5 minutes to 1.2 minutes
<FromGitter> <randiaz95> Nice~!
<FromGitter> <watzon> No problem man, feel free to ask away
<FromGitter> <randiaz95> I sent a pull request, LMK if u got it. ( The first question I have is to fully understand the result variable from the analyze method: comparative: tokens.size > 0 ? score / tokens.size : 0 ) ⏎ ⏎ What is this comparative variable for?
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #crystal-lang
<FromGitter> <watzon> As far as I remember, the comparative is supposed to evaluate the sentiment of that token in comparison with the other tokens
<FromGitter> <watzon> But it's been a while since I touched it
ur5us has quit [Quit: Leaving]
ur5us has joined #crystal-lang
<FromGitter> <randiaz95> Right, the score divided by the number of words
ur5us has quit [Ping timeout: 252 seconds]
<FromGitter> <randiaz95> I guess the hypothesis is; if there are alot of words each word carries less meaning
<FromGitter> <watzon> Yeah basically
<FromGitter> <watzon> I ported the sentiment from a node library, so I never completely understood the reason behind that
<FromGitter> <randiaz95> Im sure we could go deep into optimizing stuff but your library has all the pragmatic stuff anyways.
_ht has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
hightower2 has quit [Ping timeout: 250 seconds]
<FromGitter> <watzon> @oprypin got drawing working. trying to recreate that histogram example.
ur5us has quit [Ping timeout: 252 seconds]
chachasmooth_ has quit [Quit: Quit]
chachasmooth has joined #crystal-lang
<FromGitter> <straight-shoota> wow, when creating a new PR GitHub notifies my that the contribution guidelines have changed since my last contribution (which was in #9103).
<FromGitter> <watzon> They're making some nice progress