jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
HumanG33k has joined #crystal-lang
duane has quit [Read error: Connection reset by peer]
zorp has quit [Read error: Connection reset by peer]
Liothen has quit [Quit: Liothen]
Liothen has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
zorp has joined #crystal-lang
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 256 seconds]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
zorp has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
Nekka has quit [Ping timeout: 240 seconds]
Nekka has joined #crystal-lang
DTZUZU has quit [Ping timeout: 240 seconds]
DTZUZU has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
_whitelogger has joined #crystal-lang
Stephanie has joined #crystal-lang
Stephanie has quit [Excess Flood]
Stephie has quit [Ping timeout: 246 seconds]
Vexatoast has quit [Ping timeout: 260 seconds]
Stephie has joined #crystal-lang
Vexatos has joined #crystal-lang
Stephie has quit [Client Quit]
Vexatos has quit [Ping timeout: 260 seconds]
Vexatos has joined #crystal-lang
Stephie has joined #crystal-lang
Stephie has quit [Excess Flood]
Stephie has joined #crystal-lang
<yxhuvud> lbarasti: runnables only contain fibers that are waiting for execution but not executing yet. It does not contain the actually running threads and also not the ones waiting for io or sleeping or whatever.
<yxhuvud> additionally, it is not a thread safe interface - not only is the way you list them inherently racy, there is also that runnables is a normal deque and unsafe - ie it not intended to be accessed from outside the scheduler.
<yxhuvud> (and no, there is currently no way to access what you want)
<FromGitter> <phykos> I am new to concurrency in Crystal and I wrote this code: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ this prints `1` and runs forever until I manually interrupt it. ... [https://gitter.im/crystal-lang/crystal?at=5f82c96a60efef1ec3744980]
<FromGitter> <phykos> I mean is this the correct behavior?
<FromGitter> <grkek> I think that the receive function will wait forever until it receives something.
<FromGitter> <phykos> uhh right
<FromGitter> <phykos> btw, what does capacity mean when you construct a channel?
<FromGitter> <phykos> I mean the only argument Channel.new takes
<FromGitter> <grkek> How many calls can be captured in the queue probably
<FromGitter> <grkek> c.send(T) where T is any type you want
<FromGitter> <grkek> and when you send the data there probably is a queue which gathers up the information for the c.receive function
<FromGitter> <grkek> :)
<FromGitter> <phykos> its documentation time
<FromGitter> <grkek> Good luck ;)
<FromGitter> <AlesLulak> Hi, hopefully there is a space for a newbie question. I use hash as `options`, the hash value is an union type (Bool | Int32 | String), but I have a method accepting only exact types as arguments. So I created a kind of hack, but I am not sure is this a good solution. Is there a better way to achieve this? Sending example: ⏎ ⏎ ```code paste, see link``` [https://g
<FromGitter> ... itter.im/crystal-lang/crystal?at=5f82d42424a20801a8dd34f4]
<FromGitter> <phykos> @asterite I have to set that value right before calling `STDOUT.write_byte`? ⏎ I defined a function where basically it does what it has to do, including writing to the stdout, but it does nothing, it keeps the things as they were before
<FromGitter> <phykos> @AlesLulak tip: sometimes the return keyword isn't even needed in Crystal, much like Ruby
<FromGitter> <HertzDevil> @AlesLulak use a NamedTuple instead, no need for unions here
<FromGitter> <HertzDevil> `options = {int: 123, str: "string", truth: true}`
<FromGitter> <phykos> also type just `value` instead of checking the truthiness of `value`
<FromGitter> <HertzDevil> (though it will be a value instead of reference in that case)
<FromGitter> <HertzDevil> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f82d71cdc95072254cc734c]
<oprypin> AlesLulak, yes the only real problem in that code **is** the fact that `options` is a mixed `Hash`
<FromGitter> <lbarasti> > *<yxhuvud>* runnables only contain fibers that are waiting for execution but not executing yet. It does not contain the actually running threads and also not the ones waiting for io or sleeping or whatever. ⏎ Makes sense, thanks, this clarifies it for me. ⏎ ⏎ > *<yxhuvud>* additionally, it is not a thread safe interface - not only is the way you list them inherently racy, there is also that runnables
<FromGitter> ... is a normal deque and unsafe - ie it not intended to be accessed from outside the scheduler. ⏎ Yes, this I appreciate, and do understand the risk. Anyhow, I'll open a forum topic to gather all these info, really appreciate you chiming in 👍 [https://gitter.im/crystal-lang/crystal?at=5f82d9046e1aa94de7f155ab]
<FromGitter> <lbarasti> > *<yxhuvud>* additionally, it is not a thread safe interface - not only is the way you list them inherently racy, there is also that runnables is a normal deque and unsafe - ie it not intended to be accessed from outside the scheduler. ⏎ ⏎ Yes, this I appreciate, and do understand the risk. Anyhow, I'll open a forum topic to gather all these info, really appreciate you chiming in 👍
<FromGitter> <AlesLulak> @HertzDevil aha! Thank you. I must read through the references, I forgot about NamedTuple. ⏎ @oprypin sorry, what does a mixed hash exactly mean?
<oprypin> AlesLulak, `{} of Symbol => (Int32 | String | Bool)` mixed because its values are a union type
<FromGitter> <AlesLulak> oh, sure. And that's a bad approach, right?
<oprypin> AlesLulak, usually yes. you can see it's bad because of the problems you're running into :)
<FromGitter> <AlesLulak> thanks for the insight
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
twistedpixels has quit [*.net *.split]
twistedpixels has joined #crystal-lang
postmodern has quit [Quit: Leaving]
scott_tams has joined #crystal-lang
<scott_tams> hello...is it possible to store an Array of classes or Hash of string to classes, to then later access methods on all of them?
<FromGitter> <Blacksmoke16> like iterate the methods on that type at runtime?
<scott_tams> no, call the same method on a bunch of classes
<scott_tams> all the classes implement =~ so I want to check all of them and see if they match
<FromGitter> <Blacksmoke16> oh yea that should be possible
<FromGitter> <Blacksmoke16> `types.all? &.=~(pattern)`
<scott_tams> but what type would `types` have? `Array(Class.class)` doesn't work
<FromGitter> <Blacksmoke16> is `=~` a class method? I'd assume no?
<scott_tams> yes it is.
<scott_tams> each class has a set of 5 constants, `=~` is implemented to check if any of them match
<scott_tams> sorry, 3. Abbreviation, singular, and plural
<FromGitter> <Blacksmoke16> i see
<FromGitter> <Blacksmoke16> https://carc.in/#/r/9tll
<FromGitter> <Blacksmoke16> cant define abstract class methods
<scott_tams> ah but that works. Close enough.
<FromGitter> <Blacksmoke16> could also just do like
<FromGitter> <Blacksmoke16> https://carc.in/#/r/9tlq
<FromGitter> <Blacksmoke16> build out the array of types at compile time
<scott_tams> Ah that's perfect. I was trying to do it without the parent class and they aren't all within the same module so it was just not working lol
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> do you have an example of what you're ultimately trying to do?
<FromGitter> <Blacksmoke16> if the values you're comparing as part of `=~` are known at compile time you could do that logic also at compile time
<scott_tams> I have a json document with many types which I then use to generate a Crystal library (and a C++ one as well) to convert between all the different unit types in the document.
<scott_tams> I'm adding a CLI to the Crystal library, so when you pass the command, for example `1000 mm to meters` it will find the classes associated with `mm` and `meters`, and eventually call `Millimeter.new(count).to "m"`
<scott_tams> or rather, `.to Meter.abbr`
<FromGitter> <Blacksmoke16> fair enough
<scott_tams> whoo I got it working! Thanks @Blacksmoke16, I knew you could help :joy:
<FromGitter> <Blacksmoke16> np
<FromGitter> <RespiteSage> Ooh. Someone's working on a Unit library?
<FromGitter> <RespiteSage> / application?
<scott_tams> yeah it's working just gotta put some polish on it.
<FromGitter> <RespiteSage> I look forward to seeing it (assuming it's open-source). :)
scott_tams has quit [Remote host closed the connection]
Stephie has quit [Quit: Fuck this shit, I'm out!]
Vexatoast has joined #crystal-lang
Vexatos has quit [Ping timeout: 260 seconds]
Stephie has joined #crystal-lang
Stephie has quit [Excess Flood]
Stephie has joined #crystal-lang
duane has joined #crystal-lang
ryanprior has quit [Quit: authenticating]
Seich has quit [Quit: Gone fishing.]
Seich has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <j8r> scott_tams: what you said remind me a French comedy movie: https://www.youtube.com/watch?v=cyQtMZBZJlk :)
<FromGitter> <j8r> auto-captions + english translation is decent in this video
yukai has joined #crystal-lang
<FromGitter> <incognitorobito> Hey folks, I'm trying to build the compiler on Windows and I keep hitting a linker error with LLVM. Has anyone seen this before?
<FromGitter> <incognitorobito> I thought that function was getting built as apart of that lib, but is there something I'm missing?
<FromGitter> <Blacksmoke16> i assume you're aware Crystal isn't 100% supported on Windows yet right?
<FromGitter> <incognitorobito> Yes, I'm working on support for Windows
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows is pretty up to date afaik, might be worth a look if you havent already
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
<FromGitter> <Blacksmoke16> `Error: Deprecated is not an annotation, it's a annotation` :D
<FromGitter> <Blacksmoke16> nvm, bug in my code
Human_G33k has quit [Read error: Connection reset by peer]