jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.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
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <watzon> Macros aren't scoped, are they?
<FromGitter> <Blacksmoke16> scoped to what? like class?
<FromGitter> <watzon> Yeah class or module
<FromGitter> <Blacksmoke16> i think so?
<FromGitter> <watzon> Hmm I guess they are
<FromGitter> <watzon> Good
<FromGitter> <watzon> I was afraid that they were global
<FromGitter> <Blacksmoke16> pretty sure if you declare them as private on top level, they are limited to that file
oprypin has quit [Quit: No Ping reply in 180 seconds.]
oprypin has joined #crystal-lang
<FromGitter> <tenebrousedge> crystal can scope methods to a single file?
DTZUZO has quit [Ping timeout: 252 seconds]
<FromGitter> <tenebrousedge> I wonder if that would let you write something like Ruby's refinements
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <tenebrousedge> Refinements are useful for extending core classes, but only in a single file/class
<FromGitter> <Blacksmoke16> ah gotcha
<FromGitter> <Blacksmoke16> anyone know if its possible to have vars scoped to a fiber?
<FromGitter> <Blacksmoke16> like an ivar specific to that fiber
<FromGitter> <tenebrousedge> a fiber uses a proc, right? shouldn't variables be scoped within that proc?
<FromGitter> <Blacksmoke16> i was more so imaging like during an http request, which spawns a fiber, id like all my code that gets executed to have access to an ivar but that would be specific to that request, i.e. fiber
<FromGitter> <Blacksmoke16> im doubting that is doabl
<FromGitter> <tenebrousedge> you could just add one to the class?
<FromGitter> <Blacksmoke16> class wouldnt be concurrent safe, since there could be two requests, i.e. two fibers, with only one class var
<FromGitter> <Blacksmoke16> i suppose you could give a fiber a name, and use same name as a key in some top level class hash and assign the instance to that hash, but that seems kinda hacky
<FromGitter> <tenebrousedge> well, sure, but couldn't you just do `class Fiber; property @myprop; end` ?
<FromGitter> <Blacksmoke16> :0
<FromGitter> <Blacksmoke16> 😮
<FromGitter> <Blacksmoke16> yea that might do it
<FromGitter> <Blacksmoke16> lol i swear if if thats simple
<FromGitter> <tenebrousedge> 👍
<FromGitter> <Blacksmoke16> let me try it
<FromGitter> <Blacksmoke16> that might work
<FromGitter> <Blacksmoke16> `Fiber.current.container = ServiceContainer.new`
<FromGitter> <tenebrousedge> is good?
<FromGitter> <Blacksmoke16> seems pretty solid
<FromGitter> <Blacksmoke16> good call dude!
<FromGitter> <Blacksmoke16> i would have never thought of that
<FromGitter> <tenebrousedge> you're very welcome :)
<FromGitter> <Blacksmoke16> now to move on to the other challenges :p
<FromGitter> <Blacksmoke16> heres another question
<FromGitter> <Blacksmoke16> i guess the question, can you clone an obj so that it doesnt reference the original?
<FromGitter> <Blacksmoke16> i think thats what `dup` is for?
<FromGitter> <tenebrousedge> I would think so, yeah
<FromGitter> <Blacksmoke16> cool perfect
alexherbo22 has joined #crystal-lang
alexherbo22 has quit [Client Quit]
alexherbo27 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo27 is now known as alexherbo2
laaron has quit [Remote host closed the connection]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 258 seconds]
Raimondii is now known as Raimondi
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> `Array(Athena::DI::FeedPartner) <= Athena::DI::FeedPartner` shouldn't this evaluate to true?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.28.0/Class.html#T.class%29%3ABoolforallT-class-method
<FromGitter> <Blacksmoke16> `Returns whether this class inherits or includes other, or is equal to other.`
<FromGitter> <Blacksmoke16> nvm, was missing `.class`
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
Raimondii has joined #crystal-lang
blassin4 has joined #crystal-lang
pracabor has joined #crystal-lang
blassin has quit [Ping timeout: 258 seconds]
robacarp has quit [Ping timeout: 258 seconds]
Raimondi has quit [Ping timeout: 258 seconds]
Raimondii is now known as Raimondi
DTZUZO has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
olbat[m] has quit [Read error: Connection reset by peer]
beepdog has quit [Remote host closed the connection]
dkowis is now known as beepdog
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
waheedi has joined #crystal-lang
DTZUZO has quit [Ping timeout: 258 seconds]
olbat[m] has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <watzon> Man creating these models for the Github API is taking forever
<FromGitter> <watzon> I think I'm about half way there https://github.com/watzon/octokit.cr/tree/master/src/octokit/models
waheedi has quit [Quit: waheedi]
notdaniel has joined #crystal-lang
notdaniel has quit [Client Quit]
moei has joined #crystal-lang
_whitelogger has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 245 seconds]
alexherbo2 has joined #crystal-lang
DTZUZO has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
lucasb has joined #crystal-lang
<FromGitter> <MrSorcus> Could someone help? ⏎ How correct to iterate array of pointers? ⏎ For example ⏎ ⏎ ```code paste, see link``` ... [https://gitter.im/crystal-lang/crystal?at=5cd6c807da34620ff922d84e]
<FromGitter> <Blacksmoke16> wouldnt it be better to use a slice?
<FromGitter> <tenebrousedge> this article on iteration is about Ruby, but also applies to Crystal http://jeromedalbert.com/ruby-how-to-iterate-the-right-way/
<FromGitter> <Blacksmoke16> if he uses a slice could use .each yea
<FromGitter> <MrSorcus> > wouldnt it be better to use a slice? ⏎ ⏎ Hmm, maybe better. But i can't find a method for getting pointer's size. 😕
<FromGitter> <MrSorcus> > this article on iteration is about Ruby, but also applies to Crystal http://jeromedalbert.com/ruby-how-to-iterate-the-right-way/ ⏎ ⏎ Thanks.
<FromGitter> <Blacksmoke16> yea im not super familiar with pointers and stuff
<FromGitter> <MrSorcus> > yea im not super familiar with pointers and stuff ⏎ ⏎ Oh, ok. Thanks you anyway.
<FromGitter> <r00ster91> A pointer doesn't have a size. A slice does
<FromGitter> <r00ster91> > a pointer doesn't know where it's pointing to nor how much memory starting from it is valid.
<FromGitter> <MrSorcus> > A pointer doesn't have a size. A slice does ⏎ ⏎ Hmm. And how to create Slice without size? 😕
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <tenebrousedge> what are you trying to do?
Yxhuvud has quit [Ping timeout: 248 seconds]
<FromGitter> <MrSorcus> > what are you trying to do? ⏎ ⏎ Just write a little binding for C function, that contain options array.
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6w9m how would you get this to work?
Yxhuvud has joined #crystal-lang
<FromGitter> <Blacksmoke16> i apparently tried all the combinations i can think of except the correct one
<FromGitter> <MrSorcus> > https://play.crystal-lang.org/#/r/6w9m how would you get this to work? ⏎ ⏎ Who?
<FromGitter> <Blacksmoke16> anyone in general that has an answer ;P
<FromGitter> <tenebrousedge> what's `<=` do there?
<FromGitter> <Blacksmoke16> it should do https://crystal-lang.org/api/0.28.0/Class.html#T.class%29%3ABoolforallT-class-method
<FromGitter> <tenebrousedge> so like `is_a?`
<FromGitter> <Blacksmoke16> kinda yea
<FromGitter> <tenebrousedge> so why would `Array` be a `FeedPartner` ?
<FromGitter> <Blacksmoke16> because the array contains the type `FeedPartner`
<FromGitter> <tenebrousedge> but it does not include that type
<FromGitter> <Blacksmoke16> how you figure?
<FromGitter> <Blacksmoke16> `type_restriction` is `Array(FeedPartner)`
<FromGitter> <tenebrousedge> it's not part of the object heirarchy
<FromGitter> <Blacksmoke16> so in theory it should b like `Array(FeedPartner) <= FeedPartner` which im thinking should be true since self includes other
<FromGitter> <tenebrousedge> `<=` seems to test the inheritance chain, not what's in the container
<FromGitter> <Blacksmoke16> `includes other.` makes me think it would be testing for the types in the generic as well?
<FromGitter> <tenebrousedge> your example seems to imply otherwise
<FromGitter> <Blacksmoke16> apparently so :p
<FromGitter> <tenebrousedge> I mean, I could easily be wrong
<FromGitter> <Blacksmoke16> i guess all i want to do is determine if an array contains another type
<FromGitter> <Blacksmoke16> macro land it would be easier
<FromGitter> <tenebrousedge> it does sound like you want to do some metaprogramming
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <Blacksmoke16> trying to at least haha
<FromGitter> <Blacksmoke16> might have to think of plan b
<FromGitter> <tenebrousedge> 1) collect underpants ⏎ 2) ??? ⏎ 3) profit!
<FromGitter> <Blacksmoke16> Hehe
rohitpaulk has joined #crystal-lang
waheedi has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
waheedi has quit [Quit: waheedi]
waheedi has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
waheedi has quit [Ping timeout: 258 seconds]
return0e has quit [Remote host closed the connection]
beepdog has quit [Quit: lol]
beepdog has joined #crystal-lang
dkowis has joined #crystal-lang
<FromGitter> <watzon> Wrote a new Crystal article: https://medium.com/@watzon/doing-crystal-1-dc441aabb791
<FromGitter> <watzon> I'll be publishing it later today, so any suggestions would be appreciated before then
<FromGitter> <dscottboggs_gitlab> you said "you're in for a treat" twice in paragraph two
<FromGitter> <tenebrousedge> the brainfuck benchmark might be a thing, but I think you might want to use a euphemism. "leading benchmark" or "standard benchmark"
<FromGitter> <malkomalko> Anybody know a good way of debugging or at least printing out some backtraces?
<FromGitter> <malkomalko> I have a part of my code that's being called more than I'd expect and just trying to figure out the best way to debug it
<FromGitter> <malkomalko> I did some searching and looking at the guides but didn't see anything
<FromGitter> <dscottboggs_gitlab> @watzon I really like the article.
<FromGitter> <dscottboggs_gitlab> @malkomalko you can load up your program in lldb or gdb
<FromGitter> <tenebrousedge> I would also avoid comparisons with steaming piles of cow dung
<FromGitter> <dscottboggs_gitlab> `crystal build --debug src/project.cr && lldb project`
<FromGitter> <dscottboggs_gitlab> @tenebrousedge I thought that was pretty spot on 😉
<FromGitter> <dscottboggs_gitlab> @malkomalko I think there's also a macro to print the stack trace but I'm not sure
<FromGitter> <malkomalko> Ok, I'll take a look at the macro and thanks for the lldb tip
<FromGitter> <tenebrousedge> I dislike C++ code as much as anyone but there's no reason to be crude
<FromGitter> <dscottboggs_gitlab> I don't see the reason for *not* being crude
<FromGitter> <tenebrousedge> if you happened to really like C++ this would tend to dissuade you from considering the merits of the author's arguments
<FromGitter> <dscottboggs_gitlab> I think anyone who would switch from C++ to Crystal would do so because they were dissatisfied with the syntax
moei has quit [Quit: Leaving...]
<FromGitter> <malkomalko> Ok, I can just `begin ... rescue ex ... end` and `puts ex.backtrace`
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
<FromGitter> <dscottboggs_gitlab> oh, yeah that's an idea
alexherbo2 has joined #crystal-lang
<FromGitter> <tenebrousedge> I don't think that there are any good arguments against civility
<FromGitter> <dscottboggs_gitlab> Idk i just don't see the harm in expressing one's opinions
alexherbo2 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> @malkomalko you can also do `CallStack.new.printable_backtrace.join('\n')` https://carc.in/#/r/6wdv
<FromGitter> <dscottboggs_gitlab> it seemed a little silly to me to raise an exception just to get to the backtrace -- but `CallStack` is an undocumented part of the stdlib so maybe that's the way you're supposed to do it...
<FromGitter> <malkomalko> I just added a little snippet so I'll stick with the rescue approach, I won't use it very often
<FromGitter> <dscottboggs_gitlab> 👍 yeah usually lldb or `pp!` is enough in my experience
<FromGitter> <watzon> > I dislike C++ code as much as anyone but there's no reason to be crude ⏎ ⏎ I see your point, but it's part of my humour lol. Even people who generally like C++ have to understand that an optimized C++ script looks like crap
<FromGitter> <asterite> there's `caller`, like in Ruby, to get the call stack
<FromGitter> <dscottboggs_gitlab> Is there an example anywhere?
<FromGitter> <malkomalko> nice and thanks!
return0e has joined #crystal-lang