ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | 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
dwdv has quit [Ping timeout: 246 seconds]
sz0 has joined #crystal-lang
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 240 seconds]
<FromGitter> <christopherzimmerman> Is it possible to pass an operator into a macro? I tried passing it as a symbol (`:+`) and as normal but it won't parse.
<FromGitter> <christopherzimmerman> Nevermind looks like you cannot (https://github.com/crystal-lang/crystal/issues/8202)
<FromGitter> <Blacksmoke16> 👍
f1reflyylmao has quit [Ping timeout: 264 seconds]
f1refly has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
f1refly has quit [Ping timeout: 276 seconds]
f1refly has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
absolutejam2 has joined #crystal-lang
<FromGitter> <watzon> Is there no way to get instance methods and variables in macros still?
ht__ has joined #crystal-lang
dwdv has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> @christopherzimmerman nice, what kinda project are you working on?
absolutejam2 has quit [Ping timeout: 265 seconds]
<FromGitter> <bararchy> Is Process MT safe ?
ua has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
<oprypin> bararchy, purely by the idea, it really should be
<oprypin> coud have bugs tho
DTZUZO has quit [Ping timeout: 246 seconds]
ua has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <bararchy> "coud have bugs tho" here be dragons
<FromGitter> <bararchy> :)
<FromGitter> <bararchy> I saw MT horrors in the last 24h that I'm too afriad to trust the "should" notion
<FromGitter> <bararchy> hahaha
DTZUZO has quit [Ping timeout: 276 seconds]
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
alexherbo2 has joined #crystal-lang
absolutejam2 has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 245 seconds]
DTZUZO has joined #crystal-lang
absolutejam2 has quit [Ping timeout: 245 seconds]
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 252 seconds]
DTZUZO has joined #crystal-lang
ht__ has quit [Ping timeout: 276 seconds]
ht__ has joined #crystal-lang
<FromGitter> <Blacksmoke16> @watzon can get class methods, just not variables iirc
<FromGitter> <bararchy> btw, does Mutex.synchronize stops the world or just makes sure this specific blocks get executed by a single Fiber each time?
<FromGitter> <asterite> the latter
<FromGitter> <asterite> synchronize calls lock before entering the block, unlock when exiting. You can imagine a fiber trying to enter the block. If it's unlocked it enters and locks, and until unlocking no other fiber can enter because it's locked
<FromGitter> <asterite> mutex exist in almost every language, maybe there's a wiki page or article about them
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db44dd8fb4dab784a0ce077]
<FromGitter> <ilanpillemer> what is a more idiomatic way to determine height of tree?
<FromGitter> <ilanpillemer> or is this the idiomatic way?
<FromGitter> <tenebrousedge> that's close enough. I'd just use `while current` though
<FromGitter> <tenebrousedge> or `until current.nil?`
<FromGitter> <ilanpillemer> ahh right.. there is truthy falsy thing
<FromGitter> <ilanpillemer> nil is false?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <ilanpillemer> and non nil is always true?
<FromGitter> <Blacksmoke16> no
<FromGitter> <tenebrousedge> `nil` and `false` are false
<FromGitter> <Blacksmoke16> only `nil` and `false` are false
<FromGitter> <ilanpillemer> thanks
<FromGitter> <ilanpillemer> loop until?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <tenebrousedge> there is a `loop do`
<FromGitter> <tenebrousedge> I think
<FromGitter> <tenebrousedge> yes
<FromGitter> <tenebrousedge> but `until condition` is probably better
<FromGitter> <ilanpillemer> except I dont it to run if parent is already nil
<FromGitter> <ilanpillemer> that sounds like at least once
<FromGitter> <ilanpillemer> and I dont want at least once
<FromGitter> <tenebrousedge> no, it won't execute if the condition is false
alexherbo29 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 265 seconds]
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db44fde9825bd6bacd178da]
<FromGitter> <tenebrousedge> you could probably do `while (current = current. parent); h += 1; end`
<FromGitter> <ilanpillemer> what is that ; thing? is this a macro?
<FromGitter> <tenebrousedge> end of line
<FromGitter> <tenebrousedge> `def initialize(@foo); end`
<FromGitter> <ilanpillemer> ok
<FromGitter> <tenebrousedge> I'm too lazy to write it out with linebreaks D:
<FromGitter> <ilanpillemer> formatter put then back in
<FromGitter> <tenebrousedge> oh I'm sure
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db450dde1c5e91508dbaacd]
<FromGitter> <tenebrousedge> `while (current = current.try &.parent)`
<FromGitter> <ilanpillemer> nah
<FromGitter> <tenebrousedge> *shrugs*
<FromGitter> <ilanpillemer> thats getting less readable now
<FromGitter> <ilanpillemer> until is nicer
<FromGitter> <ImAHopelessDev_gitlab> :D :D :D
<FromGitter> <ImAHopelessDev_gitlab> Good morning!!!
<FromGitter> <ilanpillemer> morning
<FromGitter> <Blacksmoke16> `while (p = parent) && (current = p.parent)`
<FromGitter> <joaoeudes7> Hi, have something plugin to autocomplete in VSCode?
<FromGitter> <tenebrousedge> there are a few Crystal plugins, but they're not that great
<FromGitter> <joaoeudes7> :(
<FromGitter> <joaoeudes7> An autocomplete plugin would help me in learning
<FromGitter> <joaoeudes7> https://github.com/TechMagister/cracker Deprecated??
<FromGitter> <tenebrousedge> ask the author
<FromGitter> <joaoeudes7> ok
<FromGitter> <joaoeudes7> thanks
absolutejam2 has joined #crystal-lang
alexherbo29 has quit [Ping timeout: 240 seconds]
alexherbo29 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <kingsleyh> if anyone uses MacOS and likes to switch between Crystal versions - I just wrote this super simple version switcher: https://github.com/kingsleyh/ball
rohitpaulk has quit [Remote host closed the connection]
<Yxhuvud> Hmm. I'm fiddling with C bindings. Anyone know if I can define unions inside a struct definition, or do I have to give it a name and define it outside the struct?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/reference/syntax_and_semantics/c_bindings/union.html prob would have to define one of these outside of it
absolutejam2 has quit [Ping timeout: 245 seconds]
<FromGitter> <j8r> @kingsleyh there is https://github.com/pine/crenv
<FromGitter> <j8r> what's the advantage of yours?
<FromGitter> <j8r> and why using a global `/usr/local/bin`?
<FromGitter> <j8r> another thing, it should not have directories inside `/bin`
<FromGitter> <ochran> Hello, how do I create optional url params in Kemal? In Sinatra you would do something like get "/resource/?:optional_param?"
<FromGitter> <Blacksmoke16> i dont think you can, it uses radix trees under the hood so that would have to support it
<FromGitter> <ochran> Ah okay, the only alternative I could find is: https://github.com/kemalcr/kemal/issues/149
<FromGitter> <ochran> But that doesn't seem to be exactly what I want, but will have to do. Cheers sir
<FromGitter> <kingsleyh> @j8r pine didn't work for me - and it doesn't look like it's maintained much - /usr/local/bin is convenient for my purposes - but I should probably move the directories into /usr/local
DTZUZO has joined #crystal-lang
<FromGitter> <tenebrousedge> `/usr/local/bin` should be `~/.local/bin`
<FromGitter> <kingsleyh> if I move it to a local path then it will only work for me - and I need to switch users often which why I put it in /usr/local/bin - but I could make that configurable - although I'm not expecting anyone else to use my ball library really - but it's convenient for me
<FromGitter> <Blacksmoke16> whats the use case for switching versions a lot?
<FromGitter> <Blacksmoke16> older libs that arent up to date anymore?
<FromGitter> <kingsleyh> many of my apps are broken by new releases - and it takes quite some time to migrate them
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <kingsleyh> in the past I just stayed up to date all the time - but the most recent releases caused a large amount of breakage
<FromGitter> <ilanpillemer> part 2 is taking forever
<FromGitter> <ilanpillemer> Woot!
<FromGitter> <ilanpillemer> it completed
<FromGitter> <gdotdesign> @kingsleyh there is https://asdf-vm.com/ it has a crystal plugin don't know if it's up to date or now
<FromGitter> <j8r> agree 💯 with @tenebrousedge
<FromGitter> <Blacksmoke16> finally getting back to the serialization thing
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db48dae9c398215098cdc6b]
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <Blacksmoke16> er should be `myAddress`, i fixed it
<FromGitter> <Blacksmoke16> but cant edit anymore so welp
sagax has quit [Quit: Konversation terminated!]
Groogy has joined #crystal-lang
Groogy has quit [Client Quit]
<FromGitter> <bararchy> I really really want a niceness level for Fibers
<FromGitter> <bararchy> spawn(-19) do ⏎ ⏎ end
<FromGitter> <bararchy> or some similar method to indicate which Fibers are more important and which a are less so
<FromGitter> <tenebrousedge> that would be nice, but should Crystal implement that in core?
<FromGitter> <bararchy> what I said or @Blacksmoke16 ?
<FromGitter> <tenebrousedge> you
<FromGitter> <bararchy> so, adding something like that means integration with the scheduler, and all concurrency model
<FromGitter> <bararchy> so I guess it has to go into Core
<FromGitter> <tenebrousedge> hmmm
<FromGitter> <straight-shoota> Well, technically you can reopen the scheduler or write your own
<FromGitter> <bararchy> I'm sure I can, but won't something like that be valuable for multiple people?
<FromGitter> <straight-shoota> Maybe
<FromGitter> <bararchy> as in, you can say "This Fiber is the most important, before scheduling other Fibers, make sure he don't want to get wake up"
<FromGitter> <straight-shoota> I'm sure you can already do that by manually enqueing the respective fiber.
<FromGitter> <straight-shoota> The scheduler implementation has changed a bit since MT and I'm not overly familiar with its workings after that, but it should be possible
<FromGitter> <bararchy> hmmmmmmmmmmmmm
<FromGitter> <bararchy> interesting
<FromGitter> <bararchy> ?
<FromGitter> <straight-shoota> yes
<FromGitter> <bararchy> will that mean "make this Fiber be tested now!" sort of thing? or just to put it in the end of the queue?
<FromGitter> <straight-shoota> It means it is added to the runnables queue. This queue is worked off when a fiber yields
<FromGitter> <straight-shoota> So it might not be executed immediately at the next fiber switch if other fibers are ready and in the runnables queue, but pretty soon
gangstacat has quit [Ping timeout: 276 seconds]
ht__ has quit [Ping timeout: 246 seconds]
<FromGitter> <bararchy> @straight-shoota what does `.resume` means?
<FromGitter> <bararchy> isn't that what i'm looking for ?
<FromGitter> <straight-shoota> It immediately switches execution to the respective fiber
<FromGitter> <straight-shoota> It forces a context switch. The current fiber will not be continued, unless it has been enqueued before
gangstacat has joined #crystal-lang
<FromGitter> <straight-shoota> Or is resumed/enqueued again from somewhere else
<FromGitter> <ilanpillemer> ``` program = {"cpy" => self.cpy} ⏎ ⏎ def self.cpy(x, y) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5db4af76e469ef43586e5433]
<FromGitter> <ilanpillemer> whats the correct way to refer to a function in a hash?
<FromGitter> <Blacksmoke16> So you can call it later?
<FromGitter> <ilanpillemer> yes
<FromGitter> <ilanpillemer> with a lookup to the hash
<FromGitter> <Blacksmoke16> Try like ->cpy
<FromGitter> <ilanpillemer> so later on I would could do somethig like `program[“cpy”].call(a,b)`
<FromGitter> <Blacksmoke16> Yes exactly
<FromGitter> <tenebrousedge> My Forth (https://gist.github.com/tenebrousedge/de2919120f7ea68128731f67c7997190) exercise does that
<FromGitter> <ilanpillemer> ``` program = {"cpy" => self.cpy} ⏎ ⏎ def self.cpy(x, y) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5db4b02f9825bd6bacd4159d]
<FromGitter> <ilanpillemer> not quite.. it actually puts the code in the hash
<FromGitter> <Blacksmoke16> hm
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db4b07914d55a37857fe7f1]
<FromGitter> <Blacksmoke16> oh yea, need to specify the types
DTZUZO has quit [Ping timeout: 240 seconds]
<FromGitter> <ilanpillemer> 👍
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db4b18fa03ae1584f157114]
<FromGitter> <ilanpillemer> 😁
<FromGitter> <tenebrousedge> but why are those defined on `Computer` rather than normal procs?
<FromGitter> <ilanpillemer> yeah.. unnecessary
<FromGitter> <ilanpillemer> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db4b20a9c398215098dd513]
DTZUZO has joined #crystal-lang
sagax has joined #crystal-lang
<FromGitter> <Blacksmoke16> i think he meant do they need to be methods vs just directly procs
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5db4c9ac2a6494729c46970f]
<FromGitter> <Blacksmoke16> full example showing off most of the features
<FromGitter> <Blacksmoke16> turned out pretty well tbh
<FromGitter> <Blacksmoke16> https://blacksmoke16.github.io/CrSerializer/CrSerializer.html still some work to do, but merged in the main refactor
blassin has quit [Quit: The Lounge - https://thelounge.chat]
blassin has joined #crystal-lang
dostoyevsky has quit [Quit: leaving]
dostoyevsky has joined #crystal-lang