<FromGitter>
<dscottboggs_gitlab> > your module defines a method that is used at instance level, and at class leve ⏎ How='
<FromGitter>
<dscottboggs_gitlab> > > your module defines a method that is used at instance level, and at class leve ⏎ ⏎ How's that? I'm trying to use a class-/static-method on an included module within the scope of another class-/static-method, not from the scope/context of an instance method
<FromGitter>
<dscottboggs_gitlab> @Blacksmoke16
<FromGitter>
<Blacksmoke16> so you `include M`, that adds the methods as instance methods
<FromGitter>
<Blacksmoke16> you then do `S.new` which does `new method`
<FromGitter>
<Blacksmoke16> but method is defined as an instance method, so its undefined
<FromGitter>
<Blacksmoke16> at the class scope
<FromGitter>
<dscottboggs_gitlab> no, method is a class-method `def self.method`
<FromGitter>
<Blacksmoke16> idt it works like that
<FromGitter>
<Blacksmoke16> `self.method` i think is defining the method on the module's scope
<FromGitter>
<dscottboggs_gitlab> ugh
<FromGitter>
<Blacksmoke16> which doesn't get included when you `include` or `exclude` the module into another type
<FromGitter>
<Blacksmoke16> could do something like this tho
<FromGitter>
<dscottboggs_gitlab> ok so I can create a separate `module Methods` and `module ClassMethods` though
<FromGitter>
<dscottboggs_gitlab> oh, that works then!
<FromGitter>
<Blacksmoke16> so that `self.method` gets defined in the scope of the type the module is included in (which also defines `double` within that type)
<FromGitter>
<dscottboggs_gitlab> thanks George! big help
<FromGitter>
<Blacksmoke16> np
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
alexherbo26 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter>
<samuell> Can you loop over the output of a channel, similar to how you can do "range" in Go (`for val := range myChan { ...`)?
<FromGitter>
<samuell> Well, if I can check if the channel is open, I guess that should suffice too ...
<oprypin>
samuell, something like `while (val = chan.receive?)`
deavmi has quit [Ping timeout: 246 seconds]
<FromGitter>
<samuell> @oprypin Thanks, will try
<oprypin>
that go stuff is a contender for the most pointless specialized syntax
<FromGitter>
<samuell> :)
<FromGitter>
<samuell> Hmm, it seems the loop will hang forever with `while ...`. And if I close the channel it in my sender loop, I get an error for when the channel is closed. ⏎ Is there something like `defer close(myChan)` in Go?
<FromGitter>
<samuell> Ok, `ch1.receive?` (with a question mark) seems to make the trick ...
<oprypin>
yea so like i suggested lol
<FromGitter>
<samuell> Haha, ah, indeed
<FromGitter>
<samuell> Anyways, this is great. So much simpler syntax than Go.
<FromGitter>
<samuell> I'm just hoping that closing the channel in my sender-fiber won't happen before all items are received from it ... but it seems to work well.
<FromGitter>
<samuell> So, I assume the `defer` thing is not needed then.
deavmi has quit [Read error: Connection reset by peer]
deavmi_ has joined #crystal-lang
deavmi_ has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
<FromGitter>
<didactic-drunk> @samuell `receive` returns `nil` or errors after all messages are consumed.
deavmi has quit [Ping timeout: 240 seconds]
deavmi has joined #crystal-lang
<FromGitter>
<samuell> @didactic-drunk IC
sz0 has quit [Quit: Connection closed for inactivity]
deavmi has quit [Ping timeout: 246 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
HumanG33k has quit [Quit: Leaving]
sz0 has joined #crystal-lang
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
alexherbo2 has joined #crystal-lang
<FromGitter>
<Uzay-G> hey, does crystal use a garbage collector?
<rocx>
should. i don't recall any manual memory management being a normal part of it.
<yxhuvud>
@Uzay-G: Yes. It uses the Boehm collector, which is a conservative GC. It is one of the things that most probably would get rewritten at some point if the language truly take off and get largs sponsorships.
<FromGitter>
<dscottboggs_gitlab> You can also do manual memory management but the stdlib types are all GC'd
<yxhuvud>
Yes, nothing stops you from running with scissors :P
HumanG33k has quit [Quit: Leaving]
HumanG33k has joined #crystal-lang
<FromGitter>
<dscottboggs_gitlab> As it should be! 😀
<FromGitter>
<Uzay-G> hmm ok, what are the advantages of using a garbage collector instead of scopes and ownership systems like c/c++/rust
<FromGitter>
<dscottboggs_gitlab> it's easier to write, especially in edge cases. IMO it would be nice if crystal supported that as well, but the focus is on other things right now, as that sort of thing can be a bit tricky to develop, especially with readable syntax (looking at you, Rust)
<FromGitter>
<dscottboggs_gitlab> I write a bit of C and C++ and the ability to just get something done in Crystal is night and day next to the C++ alternative, let alone C. But the performance difference is not very much
<FromGitter>
<dscottboggs_gitlab> and remember, Crystal is a superset of C -- anything you can write in C you can write in Crystal, even down to inline assembly! So you've always got that escape hatch where if some part of your codebase is bottlenecking you do to GC, you can always just remove the GC from that section of code, unlike in Go for example where calling C functions involves some overhead
<FromGitter>
<wyhaines> This is the delight that I am having with Crystal. It is so damn fast -- consistent faster than equivalent Go -- but I was truly productive in it in just a few days because of all of the syntax overlap with Ruby. It's SUCH a win as a language.
<FromGitter>
<dscottboggs_gitlab> yeah go has a LOT of design decisions which make it slower than Crystal. Which kinda cracks me up, because my biggest pain point in Go is error handling. They won't implement exceptions because of the overhead, but runtime reflection on the "likely" code path is A-OK. Alrighty guys 😂
<FromGitter>
<Uzay-G> yeah the speed is nice especially coupled with the ruby syntax
<FromGitter>
<dscottboggs_gitlab> TBH I came from a Python background and barely know any ruby and found it to be very intuitive even still :)
<FromGitter>
<dscottboggs_gitlab> What is the point of the Cyclomatic Complexity error in ameba and other linters? There are some cases where you need to have a massive `case..when`, for example in parsers. The stdlib doesn't follow this convention, does it serve some important purpose?
<FromGitter>
<Blacksmoke16> It's more of a suggestion than a steadfast rule
<FromGitter>
<Blacksmoke16> I.e. "think about if you can refactor this to be simpler"
<FromGitter>
<dscottboggs_gitlab> that's fair. it can be a smell except for certain cases
<FromGitter>
<Blacksmoke16> Mhm
<FromGitter>
<wyhaines> Yeah, I've always taken the cyclomatic complexity warnings to more or less be a warning that maybe a chunk of code should be simplified, if it is reasonable to do so. As you note, there are cases where it's just unreasonable to do so.
<FromGitter>
<wyhaines> Crystal has actually made me feel conflicted. I was once an active Ruby core committer, and I have a job again now that really allows me some time to commit to things like that, so I have started looking at getting back to exercising that commit bit. But....I find working with Crystal SO INCREDIBLY rewarding, and sometimes there is time for only one or the other.
<FromGitter>
<dscottboggs_gitlab> yeah, I keep thinking to myself "this project would be so much better if I could write it in crystal" but work only allows Python, Go, Java, and C++. pretty frustrating I agree
<FromGitter>
<wyhaines> I am fortunate there. I was doing a little side project in Crystal, but it morphed into a major infrastructure component for a big, long term contract that the company has, so I am currently being paid to basically write Crystal full time, though starting next week my time is probably going to be split between the Crystal work and work on a Rails project. Still....it's kind of awesome to be earning a living
<FromGitter>
... writing Crystal even part of the time.
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo29 is now known as alexherbo2
alexherbo2 has quit [Ping timeout: 246 seconds]
<FromGitter>
<dscottboggs_gitlab> Why was the `parallel` macro dropped? 9097 (https://github.com/crystal-lang/crystal/pull/9097) doesn't say much about the rationale, besides that it's "not needed" but it's a very useful thing for end-users...
<FromGitter>
<Blacksmoke16> its in its own shard iirc
<FromGitter>
<Blacksmoke16> didnt want to have to maintain it as part of stdlib, as iirc its implementation was just an experiment
<FromGitter>
<dscottboggs_gitlab> `:info` defines the miniumum log-level output by the logger, `.info` emits a log message at the `Info` log-level
<FromGitter>
<didactic-drunk> Better error handling and several other features are planned. I'll probably change `require "concurrent/{enumerable,channel}"` to `"concurrent/stream"`
<FromGitter>
<j8r> the minimum?
<FromGitter>
<j8r> Isn't already `Trace`?
<FromGitter>
<dscottboggs_gitlab> yes so if you were to call `log.debug "something"` on that logger, nothign would show up, but (by default), `log.info` messages *will* show up
<FromGitter>
<j8r> ha ok I see, just tested it
<FromGitter>
<j8r> the methods are no doc :/
<FromGitter>
<j8r> not sure why
<FromGitter>
<j8r> thanks
<FromGitter>
<wyhaines> @didactic-drunk I was playing with your code just this morning.
<FromGitter>
<wyhaines> I may have a use case for it after it matures just a tiny bit, in the project that I am working on.
<FromGitter>
<didactic-drunk> Go on. Whatcha need?
<FromGitter>
<didactic-drunk> `map/batch/wait/run` from a Channel is probably reliable. It's in my daily workflow and ci. Error handling is less tested. If your code can't fail or you rescue yourself it's beta worthy.
<FromGitter>
<wyhaines> I will elaborate for you in a bit. I have to step away from the computer for a while.