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
<repo> no way to do it at compile time I guess
<FromGitter> <Blacksmoke16> not when using Ints at least
<FromGitter> <Blacksmoke16> it would be w/o the Int32 overload
<repo> yeah
<FromGitter> <Blacksmoke16> but is the protection of that worth the little more verbose API? probably not
<repo> Dunno
<repo> I gotta get some sleep buddy, ttl!
<FromGitter> <Blacksmoke16> catch ya later o/
<repo> o/
<wmoxam> so .. does building shards now depend on a working install of shards? πŸ€”
<FromGitter> <Blacksmoke16> eys
<wmoxam> 😭
<wmoxam> I finally got Crystal > 0.30.1 to build on OpenBSD, now I need to figure out how to bootstrap shards πŸ˜…
<FromGitter> <Blacksmoke16> moment
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <Blacksmoke16> i remember seeing a post about how to do that w/o shards
<FromGitter> <Blacksmoke16> but i dont remember where i saw it
<wmoxam> I think I'll need to write a bit of shell to checkout the correct tag from github
<FromGitter> <Blacksmoke16> there it is
<wmoxam> TY!
ur5us has joined #crystal-lang
<wmoxam> Once this is done I've got to figure out why it takes so long to build
<wmoxam> It was a couple of hours on a i3-6100
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <Blacksmoke16> does `content-length` header not get set automatically anymore?
<FromGitter> <asterite> depends on whether the output is streamed or not. If it's more than 8k, I think, it's streamed
<FromGitter> <asterite> well, chunked
<FromGitter> <Blacksmoke16> since we wouldnt know the size without reading it, which you dont want to do if you're streaming it?
<FromGitter> <Blacksmoke16> hmm yea, writing directly to response IO doenst include one
<FromGitter> <Blacksmoke16> ohh right, which is correct since `Transfer-Encoding` is `chunked`
<FromGitter> <Blacksmoke16> gotcha
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
kotrcka has left #crystal-lang ["https://quassel-irc.org - Chat comfortably. Anywhere."]
chachasmooth has quit [Ping timeout: 260 seconds]
chachasmooth has joined #crystal-lang
chachasmooth has quit [Ping timeout: 260 seconds]
chachasmooth has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <vprelovac> Hey folks, I came here looking for a Crystal developer. The kind seems to be very hard to find. Any tips?
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
_whitelogger has joined #crystal-lang
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
nowhereFast has joined #crystal-lang
<nowhereFast> I'm getting `Missing "v1.0.0:shard.yml" for "redis"` when running shards on 0.34, is there something I should be doing differently to get this working?
tuurev has joined #crystal-lang
<FromGitter> <naqvis> what action are you performing when receiving this?
<FromGitter> <naqvis> upgrade shouldn't be causing this pb
<FromGitter> <stergiom> it’s a new `shards.yml` file, the action is a typical `shards install` on an Ubuntu 18.04 box.
nowhereFast has left #crystal-lang [#crystal-lang]
<FromGitter> <naqvis> can you share yaml file contents?
zorp_ has joined #crystal-lang
zorp has quit [Ping timeout: 265 seconds]
zorp_ has quit [Ping timeout: 265 seconds]
Flipez has quit [Read error: Connection reset by peer]
Flipez has joined #crystal-lang
ur5us has joined #crystal-lang
<Andriamanitra> is there a neat way to keep track of what got required when using wild card?
<Andriamanitra> let's say i have a folder called extensions that has bunch of files with one module in each of them and i'd like to know which extensions got loaded
<FromGitter> <naqvis> wildcard will load all. But for your use-case, you can think of implementing a kind of `register_extension` function, and have that method called from each extension
<FromGitter> <naqvis> assuming extensions are valid crystal files
<Andriamanitra> yeah i was thinking of a way to call register_extension in a loop or something so i don't need to add that to each file separately
hpyc9 has quit [Quit: ZNC 1.7.5 - https://znc.in]
<FromGitter> <naqvis> each file separately
hpyc9 has joined #crystal-lang
<Andriamanitra> something along the lines of require "./extensions/*" |ext| do register_extension(ext) end
<FromGitter> <naqvis> nope, don't think you can do that
<FromGitter> <naqvis> `require` doesn't accept blocks
<Andriamanitra> yeah i know - just clarifying what i would like to do
<FromGitter> <naqvis> also doesn't it make sense to have individual extension register itself? as each one should be unique in performing some work
<Andriamanitra> i guess, in my case it will likely end up being the same exact line added to each file which violates the DRY principle
<FromGitter> <naqvis> don't think so
<FromGitter> <naqvis> as you will be calling register_extension method with different params
<FromGitter> <naqvis> I've used such approach in https://github.com/naqvis/cr-xmpp, might be worth you can take a look at how that is being used
<FromGitter> <naqvis> this is the method which is invoked from extensions to get themselves registered for type of thing they can handle
<Andriamanitra> thanks i'll check it out
<FromGitter> <naqvis> πŸ‘
ur5us has quit [Ping timeout: 260 seconds]
<repo> vprelovac: well this channel is full with crystal developers so i wouldn't say they're especially hard to find :P
<repo> what is `register_extension`? first time i'm hearing about it
<Andriamanitra> repo: oh it's just an arbitrary function in my code, nothing to do with the language itself
<repo> ah ok
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<Stephie> oprypin, why do you use RegisterWaitForSingleObject instead of WaitForSingleObject?
<oprypin> Stephie: that one is blocking
ur5us has joined #crystal-lang
<Stephie> windows will just spawn a new thread to run the callback in
<Stephie> uhh
<Stephie> yeah
<Stephie> we dont have an event loop
<oprypin> we don't?
<Stephie> no
<Stephie> not on windows
<oprypin> but like... fibers work
<Stephie> not for IO
<Stephie> just for channels
<Stephie> RegisterWaitForSingleObject will literally spawn an unrelated thread and start executing crystal code in it
<Stephie> which will make it crash as soon as there is an event loop
<Stephie> it's just, wrong
<Stephie> i dont understand how it works in the first place
<Stephie> looks like the windows event loop will be a pain
<Stephie> IOCP mostly but some threads using WaitForMultiplEvents and then posting the results to IOCPs
<Stephie> since you can't wait on handles *and* an IOCP at the same time
<Stephie> on the same thread at least
<Stephie> anyway, I'd like it if you returned wait to my implementation oprypin
<Stephie> yeah it's blocking but thats how it has to be right now
<oprypin> Stephie: in my opinion blocking is wrong by definition
<Stephie> me too
<Stephie> but this is a hack
<oprypin> i found that background io works anyway like this
<Stephie> this its to make it work
darkstardev13 has quit [Ping timeout: 260 seconds]
<Stephie> oprypin, you're adding threads to windows
<oprypin> i know
<Stephie> literally the two unstable things in crystal rn
<Stephie> together
<Stephie> working, somehow, through an act of god i do not want to debug
<Stephie> i can't merge this
<Stephie> non-blocking will have to wait until after anything else is non-blocking
darkstardev13 has joined #crystal-lang
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#9193969 (master - Replace old-style `Regex::MatchData` inspection in docs examples (#9010)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/672443385
travis-ci has left #crystal-lang [#crystal-lang]
<Stephie> how the heck *does* it work without -Dpreview_mt
<Stephie> it'll call Thread.current.scheduler
<Stephie> oh nice
<Stephie> it happens to work because on windows we stub out Thread.current to always return the main thread
<Stephie> oprypin, if there's any contention here then that code will segfault https://github.com/crystal-lang/crystal/blob/master/src/crystal/scheduler.cr#L83
<Stephie> because @lock is a noop unless -Dpreview_mt
<Stephie> basically that code working is a series of happy accidents and happening to not meet the race condition yet
<oprypin> Stephie: ok so you say getting input from any IO is simply not possible?
<Stephie> no
<Stephie> i'm saying it's always blocking
<Stephie> file io is already always blocking on linux, and sockets arent implemented on windows yet
<Stephie> so nobody notices
<Stephie> the hard part of windows is yet to come
<oprypin> Stephie: well if io is blocking and wait is blocking then this is kinda useless
<Stephie> no, it's not
<Stephie> if you wait *after* doing all your IO it's fine
<Stephie> of course, it's rather broken in a lot of usecases
<Stephie> but it's usable for some
<oprypin> ugh
<Stephie> yes
<oprypin> but would you agree that in the end this will require a thread?
<oprypin> for #wait
<Stephie> well, it'll require waiting on the handle
<Stephie> that could easily be combined into a single thread per application
<Stephie> but yes, it'll require threads
<oprypin> yea makes sense
<Stephie> but it can't be done now
<Stephie> getting process working isnt 0 to 100%
<Stephie> i mean, people think that getting libevent working on windows will save them
<Stephie> i doubt it
<Stephie> it might be a nice stopgap
<Stephie> we're gonna have to write a completely custom event loop
<Stephie> (which isnt actually hard because windows actually happens to have designed IOCP well)
<oprypin> I'd also say for the record that explicitly spawning a thread with WaitForSingleObject would be the same useless outcome but will require a thread per wait
<Stephie> yes
<oprypin> hmm also if one got threads working on Windows before having proper event loops, this implementation could get Process working earlier
<Stephie> oprypin, but obviously that's not what we'd do
<Stephie> we's spawn a proper crystal thread with all the required runtime state
<Stephie> and create something that uses WaitForMyultipleObjects
<Stephie> oprypin, just dont make extra work for yourself
<Stephie> getting process working with this limitation is enough to compile the compiler
<Stephie> i know - i've done it
<Stephie> then that makes working on sockets/eventloop/etc easier
<Stephie> since you're not in cross-compile hell
<oprypin> I'll agree with you of course, don't worry. and not just because i don't have a choice πŸ˜‚
<Stephie> i know it's frustrating that Process has this major limitation
<Stephie> it does make it a pain to use on windows
<Stephie> but then we dont have asyncio on pipes either
<Stephie> so you literally cant read to and write from a process at the same time even if this was solved
<Stephie> uhh, read from and write to
<Stephie> so, basically, you're fucked either way
<Stephie> nvm
<Stephie> IOCP solves everything
ur5us has quit [Ping timeout: 260 seconds]
<oprypin> Stephie, yea ok, io seems to still work with blocking `wait`. seems like it will always work for the typical scenario where one uses `Process.run` without a block
<oprypin> i was under the impression that it didnt work, from my prior development. but apparently i was doing something else wrong
<Stephie> yeah
<Stephie> it does work
<Stephie> in like, most cases?
<Stephie> oprypin, if you get crystal compiler working and merged i'll do all the event loop stuff
<Stephie> im actually somewhat hyped
<oprypin> getting compiler working is my aim
<Stephie> then what? burn out :P
<Stephie> well, take a break
<Stephie> thanks so much for that merge btw
<Stephie> this is looking really good
<oprypin> no problem :) :)
<Stephie> yup
<oprypin> annoyingly, this spec fails on windows https://github.com/crystal-lang/crystal/blob/9193969a76d120187448e948ba4c47960098929f/spec/std/process_spec.cr#L223 , i'll need to figure that one out
<Stephie> oprypin, I think we want to keep the PID types identical between windows and linux
<Stephie> im not sure what pidT is on linux...
<Stephie> but it'll be best to take the largest and cast around, unfortunately
<Stephie> just to make sure any code doesnt end up platform specific by accident
<Stephie> i.e. people not using foo : Process::Pid
<Stephie> people just going `foo : Int32 # lol i only compile on linux`
<oprypin> yes i think it's true. i only delayed that decision this way
<Stephie> it's a thing we've been trying to do for all of windows support
<Stephie> make the types and the methods and the entire compile time API identical
<oprypin> it can end up `alias PID = Int64` followed by fixing all compile failures
<Stephie> get the runtime behaviour as identicla as we can
<Stephie> then raise exceptions when we cn't
<oprypin> jan-zajic was changing everything to int64
<Stephie> yeah that seems sensible...
<Stephie> what DWORD again?
<Stephie> Int16?
<oprypin> UInt32
<Stephie> oh
<Stephie> nice
<Stephie> cause windows was originally 16bit
<Stephie> right
<Stephie> posix stuff tends to define it as Int32 right?
<oprypin> yes
<oprypin> so int64 is kinda overkill but what are you gonna do
sorcus has quit [Quit: WeeChat 2.7.1]
<Stephie> i mean.....
<Stephie> we could just map UInt32 to negative Int32s
<Stephie> :P
<Stephie> lol
<Stephie> of course raymond chen has
<Stephie> do we want to make the ggamble that all PIDs in all future platforms are 32bit though
<Stephie> i'd like to make it UInt64
<Stephie> at least, put it in the PR
<Stephie> and hope nobody notices
<oprypin> Stephie, do we want to make a gamble e that all PIDs in all future platforms are positive though?
<Stephie> yes
<Stephie> fuck any platform which has negative PIDs
<oprypin> ??? i want int64, i dont see why it should be uint64
<Stephie> i mean
<oprypin> oh.. no, i see
<Stephie> a platform using u64 seems a lot more likely than i64
<Stephie> idk
<oprypin> > do we want to make a gamble that all PIDs in all future platforms are less than UINT64_MAX
<oprypin> > do we want to make a gamble that all PIDs in all future platforms are less than INT64_MAX
<oprypin> damn it
<Stephie> go find out wtf fuscia's doing
<Stephie> or however you spell it
<FromGitter> <bararchy> Was anything change so that in preview_mt instance vars can't be shared between Fibers? (it seems they see a copy, not the original)
<FromGitter> <bararchy> as in, one object being changed outside of Fiber (yes useing a mutex) is invisible to the object in the other Fiber
sorcus has joined #crystal-lang
<yxhuvud> Can platforms return negative PID as error code on fork (or whatever) failure?
<yxhuvud> I guess that could be handled before the number is considered a pid though
<yxhuvud> stephie: Have you looked at all on the interfaces io_uring brings to linux? It seems *seriously* great for building event loops.
<FromGitter> <naqvis> golang treat pid as `int` of which size is system dependent, i.e either 32 or 64
<Stephie> yxhuvud, i dont want to mess with the event loop on linux for now
<Stephie> i've not looked into uring much
<Stephie> though i am aware
<Stephie> im not sure of it's scope
<Stephie> @bararchy no
<yxhuvud> Supported operations is growing every kernel release. As far as I can see, scope seems to be "almost everything that is actually done very often during runtime". Though they are not there yet.
<yxhuvud> ie you have support for stuff like async accept, fopen, fclose, fsync, poll, read, etc.
<Stephie> sounds like it'll be useful in 10 years once all the features we need are supported by every kernel we need to support
<Stephie> :)
<Andriamanitra> is there no built-in way to get a set of random numbers from a range?
<Andriamanitra> i see there's Array#sample but that seems wasteful if the range is big
<Andriamanitra> i went through that and couldn't find such things
rohitpaulk has quit [Quit: Ping timeout (120 seconds)]
rohitpaulk has joined #crystal-lang
<FromGitter> <Blacksmoke16> @repo our idea has a little speedbump
<FromGitter> <Blacksmoke16> it works great when the proc/block is assigned from the controller action
<FromGitter> <Blacksmoke16> however what about the case where you want to say, support gzipping the output for all routes?
<FromGitter> <Blacksmoke16> what are your thoughts on this concept
<FromGitter> <naqvis> Andriamanitra one quick way to generate a set of random numbers within range could be like ⏎ ⏎ ```Array(Int32).new(5,0).fill {|x| x = Random.new.rand(10..20)}.to_set``` [https://gitter.im/crystal-lang/crystal?at=5e8dc3ecc52b6a38abd12df4]
<FromGitter> <bararchy> Stephie: then I'm baffled, one fiber shows the object holding one object (its a hash), the other shows its empty. There seems to be a difference in spawn called in Initialize vs after initialization
<FromGitter> <Blacksmoke16> @repo ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e8dc471d021c45cc7d15d09]
<Stephie> @bararchy code example?
<oprypin> Andriamanitra, there's a difference if u want overlapping or non overlapping
<Andriamanitra> naqvis, that doesn't guarantee no duplicates (you might end up with only 3 or 4 elements instead of 5)
<FromGitter> <naqvis> have you tried running that?
<Andriamanitra> yes
<FromGitter> <naqvis> Set will never have duplicates
<Andriamanitra> true but if you did get duplicates the set you end up can be smaller than 5
<FromGitter> <naqvis> aah I get you
<FromGitter> <naqvis> then why not have a separate method to ensure you get required number of input in a set
<Andriamanitra> yeah i will copy python's algorithm for generating random sample from a sequence if there's no built-in way
<FromGitter> <naqvis> key take away is `Random#rand` does allow you to give it a range
<raz> hum. it would be nice if there was a compiler flag for less verbose deprecation warnings
<raz> my project currently floods the screen with almost 1k lines due to the Logger deprecation (multiple shards still use it)
erdnaxeli has left #crystal-lang ["User left"]
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#3efa459 (master - remove unreachable case-when statement (#8781)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/672484222
postmodern has quit [Quit: Leaving]
<FromGitter> <neutrinog> @vprelovac what sort of project is it?
<oprypin> Andriamanitra, it's valid to keep generating numbers in range, skipping duplicates, until you have enough.
<gangstacat> hello, what would be the correct way for a package manager to package the new shards as I get "Error: can't find file 'molinillo'", then I'm asked to run shards install...
<gangstacat> by "package manager" I mean a package builder with recipes on a distro
<FromGitter> <Blacksmoke16> might help gangstacat
<gangstacat> alright Blacksmoke16, thank you :)
rohitpaulk has quit [Quit: Ping timeout (120 seconds)]
rohitpaulk has joined #crystal-lang
dannyAAM has quit [Remote host closed the connection]
dannyAAM has joined #crystal-lang
dannyAAM has quit [Remote host closed the connection]
dannyAAM has joined #crystal-lang
rohitpaulk has quit [Quit: Ping timeout (120 seconds)]
rohitpaulk has joined #crystal-lang
<FromGitter> <randiaz95> They gave me my birthday off
<FromGitter> <randiaz95> :D
<FromGitter> <randiaz95> during quarantine :D
<FromGitter> <randiaz95> woohoo
<FromGitter> <randiaz95> lol
<FromGitter> <Blacksmoke16> dont get your birthday off regardless?
<FromGitter> <randiaz95> Yeah I didn't know that
<FromGitter> <randiaz95> I grew up working for my dad since 16 years of age lol
<FromGitter> <randiaz95> I am used to working holidays and birthdays
<FromGitter> <Blacksmoke16> that would do it :p
<FromGitter> <randiaz95> Lol
<FromGitter> <randiaz95> ( making a godiva cake at home :)
<FromGitter> <randiaz95> gonna be so good lol
<FromGitter> <vprelovac> Godiva cake? Sounds delicious. Recipe link? :)
<FromGitter> <randiaz95> lol im following my wife's instructions lol
rohitpaulk has quit [Quit: Ping timeout (120 seconds)]
Subsentient has left #crystal-lang ["Leaving"]
<FromGitter> <sanks64> Hello, guys. I would want to help with Crystal development in my free time. I've already opened an issue https://github.com/crystal-lang/shards/issues/348.
<FromGitter> <sanks64> Do you have any suggestions, corrections or something like that?
<FromGitter> <sanks64> I'm not full time open source dev :>
rocx has joined #crystal-lang
blassin has joined #crystal-lang
<blassin> hello all!
<FromGitter> <Blacksmoke16> o/
<blassin> is there a similar way to create objects in Crystal like Ruby's OpenStruct?
<blassin> not dynamically, but with a set of methods?
<blassin> other than creating a class?
<blassin> like, create a simple object with a method "version" that returns X ?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/toplevel.html#record(name,*properties)-macro ?
<blassin> oooh thanks
<blassin> you always deliver ;)
<FromGitter> <Blacksmoke16> i try
<blassin> I get undefined constant for the record I'm creating
<blassin> I mean, it is undefined... I'm just creating it. right?
<FromGitter> <Blacksmoke16> example?
<blassin> what's the prefered pastebin?
<FromGitter> <Blacksmoke16> if its not too big just do three backtick style here
<blassin> it's 16 lines
<FromGitter> <Blacksmoke16> its fine
<blassin> this is the class I'm working on now
<blassin> ```class RenderingContext @site_config : Brucite::Config::Site @theme_config : Brucite::Config::Theme getter! site_config, theme_config record BruciteInfo, version: String def initialize(@site_config, @theme_config); end def language_code site_config.language end def brucite BruciteInfo.new version: "0.0.1" end
<blassin> end```
<blassin> ```
<blassin> ach
<FromGitter> <Blacksmoke16> yea need a return after the ticks
<FromGitter> <Blacksmoke16> so they on their own line
<rocx> "error while loading shared libraries: libssl.so.1.1" when using HTTP::Client. i have libressl/libssl installed. any ideas?
<FromGitter> <Blacksmoke16> `record BruciteInfo, version : String`
<FromGitter> <Blacksmoke16> not the space after `version`
<FromGitter> <Blacksmoke16> note*
<blassin> oh of course
<blassin> dumb
<blassin> nevermind....
<blassin> thanks!
<FromGitter> <Blacksmoke16> @rocx you on macos?
<rocx> Blacksmoke16: void linux.
<rocx> "cannot open shared object file: no such file or directory" but the libressl-devel package is installed.
<FromGitter> <Blacksmoke16> hmm, a bit out of my area of familiarity
<rocx> a lot of my problems tend to be beyond a lot of peoples' familiarity
<FromGitter> <Blacksmoke16> iirc something something pkg-config and something about an env var?
<FromGitter> <Blacksmoke16> ```code paste, see link```
<rocx> hm. i'll give pkgconf a go. that seems like it might do something about it
blassin has quit [Remote host closed the connection]
<FromGitter> <Blacksmoke16> just seems it cant find where the libs are
rocx has quit [Quit: πŸ‘ developers πŸ‘ developers πŸ‘ developers πŸ‘ developers]
ur5us has joined #crystal-lang
blassin has joined #crystal-lang
blassin has quit [Remote host closed the connection]
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
rocx has joined #crystal-lang
<rocx> Blacksmoke16: yeah no dice with twiddling pkgconf.
_ht has quit [Quit: _ht]
<FromGitter> <Blacksmoke16> darn
<rocx> all i know is that it's not picking up on libssl/libcrypto or something. even ln-ing some of the libraries to *.so.1.1 doesn't do the trick.
<rocx> ah. oh well. guess i could build crystal from scratch.
<rocx> i basically need to download one of the release binaries in order to bootstrap/compile the compiler, right?
<FromGitter> <Blacksmoke16> could also try installing via snap or something
<rocx> oh. there's an rpm package on the releases.
Human_G33k has quit [Remote host closed the connection]
<rocx> eyep. rpm. should've done it that way.
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
postmodern has joined #crystal-lang
rocx has quit [Read error: Connection reset by peer]
<FromGitter> <bew> RX14 are you around? I was wondering about #6956: where does `IO#gets_peek assumes incorrectly that IO#peek returning nil is the same as returning an empty slice` ?
rocx has joined #crystal-lang