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
straight-shoota has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> oprypin: think imma end up just doing `--file NAME`
<FromGitter> <Blacksmoke16> given i only really support one file at a time its probably fine
<FromGitter> <Blacksmoke16> nvm
deavmi has quit [Ping timeout: 260 seconds]
<FromGitter> <Blacksmoke16> oo, how about `./bin/oq --input=yaml -r --arg chart stolon --arg version 1.5.10 '$version' --- data1.yml data2.yml`
<FromGitter> <Blacksmoke16> i could live with `---`
deavmi has joined #crystal-lang
<FromGitter> <drinkmorewaters> Can anyone tell me at a quick glance if there is anything 'wrong' with this code, it works but just want to make sure i'm not doing things incorrectly. Thanks! ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea8e04f97338850a2d60b85]
<FromGitter> <Blacksmoke16> :thinking:
<FromGitter> <Blacksmoke16> dont need to do assign all those ivars, using the `@type : String` syntax does that for you
<FromGitter> <drinkmorewaters> Oh right.
<FromGitter> <drinkmorewaters> Didn't know that
<FromGitter> <Blacksmoke16> also whats the reason for using a hash as `Car`?
<FromGitter> <drinkmorewaters> Coming from JS used to this.type
<FromGitter> <Blacksmoke16> like cant you just get rid of that method
<FromGitter> <drinkmorewaters> Used the hash as i wasn't sure how to get the output of the type, price etc.
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea8e0d47a24ff01b0ecdf7c]
<FromGitter> <drinkmorewaters> The return of the type
<FromGitter> <Blacksmoke16> try that
<FromGitter> <drinkmorewaters> Ok let me see
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Object.html#getter(*names,&block)-macro
<FromGitter> <Blacksmoke16> also use lower snake case for variables
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea8e122b6dd23069792ed3c]
<FromGitter> <Blacksmoke16> will need to add a `getter condition : String` as well
<FromGitter> <Blacksmoke16> class could also be called `Car` since its just a single one
<FromGitter> <drinkmorewaters> Ok so if i want to get the value i need a getter to getit
<FromGitter> <Blacksmoke16> right
<FromGitter> <drinkmorewaters> Awesome, thanks i'll look this up today
<FromGitter> <drinkmorewaters> Is it the same in Ruby?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> also look into https://crystal-lang.org/reference/syntax_and_semantics/enum.html for the condition/color
<FromGitter> <Blacksmoke16> and maybe type
<FromGitter> <drinkmorewaters> ```code paste, see link``` ⏎ ⏎ So practically the same thing [https://gitter.im/crystal-lang/crystal?at=5ea8e19a14b48f0698993981]
<FromGitter> <Blacksmoke16> gives type safety versus using a string, given type/condition/price are a defined set of options
<FromGitter> <Blacksmoke16> yup
<FromGitter> <drinkmorewaters> Great, thank you for helping. :)
<FromGitter> <Blacksmoke16> if the car is immutable you could consider using a struct as well
<FromGitter> <Blacksmoke16> np
<FromGitter> <Blacksmoke16> also `return` isnt needed in those cases, last value in the method is used as the return value
<FromGitter> <drinkmorewaters> Oh, right. Will note that.
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <william-inf> new to crystal, im trying to figure out why logger has been deprec for log, is there any notes on this? i cannot see any in release notes
<FromGitter> <Blacksmoke16> it was in the changelog, see https://github.com/crystal-lang/crystal/pull/8847
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Log.html and the docs for the new module as well
<FromGitter> <william-inf> must have missed it, thank you
<FromGitter> <Blacksmoke16> some improvements will be coming in `0.35.0` as well
<FromGitter> <william-inf> that changelog link has answered all my questions, i found the api doc a little confusing at first
teardown has quit [Ping timeout: 256 seconds]
<FromGitter> <Blacksmoke16> its deff a bit of a change
<travis-ci> crystal-lang/crystal#5401dcb (master - Log: rework setup_from_env and defaults (#9145)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/680825387
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9145 (Log: rework setup_from_env and defaults)
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#e2717c6 (master - Refactor: Use Set#add? in compiler (#9195)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/680825653
travis-ci has left #crystal-lang [#crystal-lang]
<DeBot> https://github.com/crystal-lang/crystal/pull/9195 (Refactor: Use Set#add? in compiler)
<FromGitter> <Afront> Is spawning a fiber without the `-Dpreview_mt` flag the same thing as spawing a fiber with `same_thread: true `?
<FromGitter> <Blacksmoke16> i want to say yes, as without `-Dpreview-mt`, there's only one thread, and if you do use that flag and always use `same_thread` then they would also only go on one thread?
<FromGitter> <tenebrousedge> @drinkmorewaters use a record / struct
<FromGitter> <drinkmorewaters> ```code paste, see link``` ⏎ ⏎ Not sure if that's correct way of doing it, any reason why Struct over Class? [https://gitter.im/crystal-lang/crystal?at=5ea8f55fadb0ec5c2bd1f798]
<FromGitter> <tenebrousedge> `record Car, type="clown", price = 0, condition = "mint", location : String, color : String`
<FromGitter> <tenebrousedge> struct for value objects
<FromGitter> <tenebrousedge> structs are immutable, and allocated on the stack
<FromGitter> <tenebrousedge> also `record` is very convenient
<FromGitter> <tenebrousedge> you can skip the initializer, unless you want to overload it
<FromGitter> <tenebrousedge> you can do ⏎ ⏎ ```record Foo, bar : Int32 do ⏎ def my_method(baz) ⏎ @bar + baz ⏎ end ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ea8f6570b23797ec04da293]
<FromGitter> <drinkmorewaters> So when i create a new car object?, that is immutable data now? Record is a macro? i'll need to look it up.
<FromGitter> <tenebrousedge> generally unless you really need your data structure to be mutable you should use structs
<FromGitter> <drinkmorewaters> Ok
<FromGitter> <tenebrousedge> https://crystal-lang.org/api/0.34.0/toplevel.html#record(name,*properties)-macro
<FromGitter> <drinkmorewaters> Thankyou
<FromGitter> <tenebrousedge> np
<FromGitter> <drinkmorewaters> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ea8f7f73d58de7a38e1c017]
<FromGitter> <tenebrousedge> :plus1:
<FromGitter> <drinkmorewaters> Cool, thanks!
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
zorp has quit [Ping timeout: 260 seconds]
DeBot has quit [Quit: Crystal IRC]
jhass has quit [Quit: Bye]
asterite has quit [Quit: Bye]
DeBot has joined #crystal-lang
asterite has joined #crystal-lang
jhass has joined #crystal-lang
rcvalle_ has quit [Ping timeout: 240 seconds]
rcvalle has joined #crystal-lang
straight-shoota has joined #crystal-lang
<FromGitter> <bestwebua> ```Time.now, ⏎ ^-- ⏎ Error: undefined method 'now' for Time.class``` ⏎ ⏎ Is it ok? https://crystal-lang.org/api/0.20.0/Time.html#now%3Aself-class-method [https://gitter.im/crystal-lang/crystal?at=5ea954b122f9c45c2a5ad8a1]
<straight-shoota> @bestwebua You're reading the API docs for a rather old release. `Time.now` has been removed, it's now either `Time.local` or `Time.utc`. Please refer to the current API docs at https://crystal-lang.org/api/0.34.0/Time.html
<FromGitter> <bestwebua> Thank you so much, noticeable!)
alexherbo2 has joined #crystal-lang
<FromGitter> <j8r> @bestwebua lol, you're looking at the 0.20.0 version of the API
<FromGitter> <j8r> we are at 0.34.0 now
<FromGitter> <j8r> nvm straight-shoota already responded
<straight-shoota> might still be some search engine discoverability issues
<straight-shoota> and only the latest API docs actually show the version they represent
<raz> google still sends me mostly to random versions but i feel like it's getting better
<raz> i.e. the top hit is usually >0.30, followed by a few links to the same page in older versions ;)
<raz> i wish there was a good desktop api browser. i tried dash and another one but they were just bad
<FromGitter> <tenebrousedge> devdocs.io ?
<raz> yea that was the other i tried
<FromGitter> <Blacksmoke16> just download the html and brow them in a brower?
<raz> bit better than dash, but didn't work out for me (weird electron app, iirc no tabs, etc.)
<FromGitter> <Blacksmoke16> browser
<raz> yes, maybe i'll try something like that. kinda need something that clicks with my muscle memory
<raz> thanks :D but finding them is the smaller part of the challenge ;))
<FromGitter> <Blacksmoke16> finding them?
<raz> a tarball of them
<raz> basically what i want is ^space (alfred), "api cook", enter - and the cookie docs in front of me
<FromGitter> <Blacksmoke16> ah, i mean well that would be essentially a copy of the API docs
<FromGitter> <Blacksmoke16> put it somewhere on pc and add a bookmark
<raz> you are thinking windows 95. i'm thinking... neurolink!
<FromGitter> <tenebrousedge> what OS?
<raz> the one with the vegetable
<FromGitter> <tenebrousedge> on Linux it would be possible, on macOS probably not
<FromGitter> <tenebrousedge> unless
<FromGitter> <tenebrousedge> you could probably write a utility called api
<raz> yea, i could likely be scripted... but prob not as fast and smooth as i need.
<FromGitter> <tenebrousedge> well write it in Crystal and use ElasticSearch
<raz> when crystal gets a good OSX gui library i might actually give it a shot
<FromGitter> <tenebrousedge> why not just have it open in the browser?
<raz> just needs some advanced api's for global kbd shortcut, popping up a searchbar (like alfred) etc.
<raz> because that's not an improvement over what i have now - where i end up with dozens of api tabs, many on he same page, at the end of the day
<raz> anyway, 1st world problems.... i will survive
<FromGitter> <naqvis> won't ES will be an overkill for such task? Probably something small indexing capability should be sufficient for such number of docs.
<raz> yes very much.
<FromGitter> <j8r> I think he was kidding :)
<raz> but could actually be the lesser evil, given that crystal prob doesn't have bindings to embeddable indexers yet
<FromGitter> <naqvis> oops, my bad sense of humor lol
<raz> the line between humor and despair is thin. cf. electron :P
<FromGitter> <naqvis> ROFL
<raz> "jesus, guis are hard. let's just bundle... an entire frickin browser"
<FromGitter> <naqvis> they know HDs are cheap so no one cares 😆
<FromGitter> <j8r> @naqvis was it you asking for written bytes count in IOs the last day?
<FromGitter> <j8r> should interest you: https://github.com/crystal-lang/crystal/issues/9186
<FromGitter> <naqvis> yay
<FromGitter> <naqvis> thanks @j8r
<oprypin> [14:45:21] <58afb3raz> google still sends me mostly to random versions but i feel like it's getting better
<raz> oprypin: all good, it's not a big deal for me (also i've learned to glance a the url-bar first thing). SEO is a royal pita, thanks to everyone who suffers for us to improve it ;)
<FromGitter> <Blacksmoke16> can also just emit the version and redirects to latest
<FromGitter> <Blacksmoke16> or just use `master` and call it a day
<raz> yea i thought that might work as well. just redirect to latest by default. in the rare case one really wants to see an old version they can do the extra click (at least for me that wouldn't be a big deal)
ht_ has joined #crystal-lang
_ht has quit [Ping timeout: 246 seconds]
ht_ is now known as _ht
alexherbo26 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
alexherbo26 is now known as alexherbo2
alexherbo2 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
<FromGitter> <jwaldrip> Is there a way to detect when the compiler is in release mode or not?
<FromGitter> <tenebrousedge> there's a `release` flag
<straight-shoota> jwaldrip you shouldn't alter your code based on release flag
<straight-shoota> that's purely informational and should only have an effect on compiler-side optimizations
<straight-shoota> would be a hell of debugging if your code changes in release mode
<FromGitter> <j8r> just use duckduckgo, problem solved ;)
<FromGitter> <j8r> </troll>
<FromGitter> <j8r> can I parse a string from the end?
<FromGitter> <j8r> Opposite of each_char
<yxhuvud> string.reverse..
<yxhuvud> but if the string is large then it is less fun to do it like that
<FromGitter> <naqvis> `str.size-1.downto(0) do ....`
<FromGitter> <naqvis> and use `char_at`
<FromGitter> <tenebrousedge> or `(str.size.pred).downto(0)`
<FromGitter> <naqvis> ^
<yxhuvud> once upon a time I implemented a really effective reverse_readlines in ruby. that was interesting to get fast.
<FromGitter> <j8r> I'm wondering the best way to parse `sub.other.example.com` to `"sub"` and `".other.example.com"`
<FromGitter> <tenebrousedge> regex would do that
<oprypin> @naqvis: ah yes. iterating a string in O(n^2)
<FromGitter> <j8r> yeah, no
<FromGitter> <j8r> prefer to avoid regex, less surprises. `rindex` may do the trick
<oprypin> why rindex if it's from the left?
<FromGitter> <tenebrousedge> ooookay
<oprypin> @tenebrousedge: same reaction
<FromGitter> <j8r> I need to parse from the right in my case
<FromGitter> <j8r> because one may do `sub.a.a.a.other.example.com`
<FromGitter> <tenebrousedge> that sounds like a scheme one would want to avoid
<oprypin> the problem is ill-defined, i have no idea what you want
<FromGitter> <j8r> Exactly. The only thing to know is parsing from the right is necessary
<FromGitter> <tenebrousedge> but as long as you're dealing with short strings, reverse it, and if you can, use `split('.', 2)`
<FromGitter> <j8r> Reverse is a good option
<oprypin> isn't there rsplit
<oprypin> apparently not in Crystal
<FromGitter> <tenebrousedge> `"other.example.com".reverse.split('.', 2).map(&.reverse)`
<oprypin> regex is so much clearer
<oprypin> and we're still guessing that the number of splits is what's relevant
<oprypin> and then j8r says
<oprypin> <8e55e9@j8r> because one may do `sub.a.a.a.other.example.co.uk`
<oprypin> and then i feel like some kind of machine learning algorithm
<FromGitter> <j8r> not co.uk, the right side is safe
<FromGitter> <j8r> `other.example.com` can't be touched
<FromGitter> <j8r> one would say we can just rchop
<oprypin> then literally .rchop ".other.example.com" @j8r
<FromGitter> <j8r> but the domain being configurable, that's another ENV var to set - but that's an option
<FromGitter> <j8r> and if one day, on my reverse proxy, I change `other.example.com` to `one.example.com` - not ideal to change
<FromGitter> <tenebrousedge> wouldn't you have to set the env var anyway?
<FromGitter> <j8r> no
<FromGitter> <j8r> why?
<FromGitter> <j8r> I have it with `context.request.host.to_s`
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <tenebrousedge> that should return the host, which may or may not be the same thing as the domain being served?
<FromGitter> <tenebrousedge> oh I suppose from the request
<FromGitter> <tenebrousedge> but then why an env var?
<FromGitter> <j8r> only for the `rchop` option, otherwise not needed
<FromGitter> <j8r> too bad, no `rsplit`
Human_G33k has quit [Read error: Connection reset by peer]
<FromGitter> <j8r> got this: https://carc.in/#/r/8zbk
HumanG33k has joined #crystal-lang
<straight-shoota> j8r, Char::Reader can walk backwards
<FromGitter> <naqvis> if you know the last part (domain) then why not simply `gsub` that and save this looping and offseting?
<FromGitter> <j8r> straight-shoota really? how?
<straight-shoota> And there's even a constructor for starting at the end
<FromGitter> <j8r> ha right, just seen it
<straight-shoota> Char::Reader.new(at_end: string).previous_char
<FromGitter> <tenebrousedge> or if the number of domains is constant then `reverse.split('.', 3).map(&.reverse)`
<FromGitter> <naqvis> https://crystal-lang.org/api/0.34.0/Char/Reader.html#new(*,at_endstring:String)-class-method
alexherbo2 has joined #crystal-lang
<FromGitter> <j8r> Ok I ve the previous char, but then?
<FromGitter> <naqvis> :trollface:
<straight-shoota> then you walk backwards
<straight-shoota> pos is decremented on each call to previous_char
<straight-shoota> there's currently no peek_previous_char but should be easy to add if you need it
<FromGitter> <j8r> good to know, thanks!
<oprypin> @j8r, just why are you not doing rchop
rocx has joined #crystal-lang
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
<FromGitter> <jwaldrip> More progress...
<FromGitter> <naqvis> neat 👍
<FromGitter> <j8r> oprypin because it means having to set the domain as an environment variable
Deuns has joined #crystal-lang
johnny101 has quit [Read error: Connection reset by peer]
johnny101 has joined #crystal-lang
<Deuns> Hi
<FromGitter> <Blacksmoke16> o/
<Deuns> I am trying to debug a program where the line is not executed : https://github.com/crystal-lang/crystal/blob/4401e90f001c975838b6708cc70868f18824d1e5/src/io.cr#L397
<Deuns> I tried to put a breakpoint on read_byte (L.282) but it not reached
<FromGitter> <Blacksmoke16> prob going thru the decoder no?
<Deuns> unfortunately not
<Deuns> I put a breakpoint before L.397 and it is reached
<Deuns> but seems to get stalled after that
<Deuns> I do not understand what can be wrong here
<FromGitter> <Blacksmoke16> why it gets stuck on that line?
<Deuns> that is what I wonder
<Deuns> why would it hang here ?
<FromGitter> <Blacksmoke16> got some sample code?
<FromGitter> <Blacksmoke16> is possible its reading from an empty IO waiting for input
<FromGitter> <Blacksmoke16> which is blocking
<Deuns> I am trying to launch the example at https://github.com/omarroth/lsquic.cr
<Deuns> one more information though: it works on debian and does not work from openbsd
<Deuns> so teh IO waiting might be a track to follow
<FromGitter> <Blacksmoke16> yea could be something specific to openbsd's libc bindings, but thats just a guess :shrug:
<FromGitter> <Blacksmoke16> i dont really have any ideas
<Deuns> any thing I could do to ease on debugging ? (exporting traces or something similar ?)
<FromGitter> <Blacksmoke16> reproducible code would be the big one
<FromGitter> <Blacksmoke16> ideally simple code
<Deuns> thanks Blacksmoke16
<Deuns> hum... the code path is not the same on linux and openbsd. linux goes through the decoder...
<FromGitter> <Blacksmoke16> might be a clue?
<FromGitter> <Blacksmoke16> openbsd doesnt have CI so is totally possible there is a bug somewhere
zorp has joined #crystal-lang
<FromGitter> <naqvis> Deuns are you trying to access the same URL on both boxes?
<FromGitter> <naqvis> info you have given is showing that on one box, contents have encoding/charset info, while on the other it doesn't
<FromGitter> <naqvis> default encoding is UTF-8
<Deuns> naqvis: yep
<Deuns> it is the exact same example
<FromGitter> <naqvis> try to log to console `IO#encoding` on both boxes and see, if you find any difference in output
<FromGitter> <naqvis> if both are showing the default UTF-8, then as Blacksmoke16 mentioned, might be some bug as there is no CI on openbsd or some other binding issues
<Deuns> can you elaborate on "log to console `IO#encoding`" ?
<FromGitter> <naqvis> you provided details that you have tracked down the issue to `IO` class, so either check in debugger the `encoding` property or do some output in code by calling `io.encoding` where `io` is the var via which you have reached to this point
<FromGitter> <watzon> I wonder, does anyone have experience with OpenSSL RSA?
<FromGitter> <watzon> I need to import an RSA instance from an existing private key, but I can't figure out how to do that
<Deuns> thank you naqvis!
<FromGitter> <Blacksmoke16> @watzon https://github.com/stakach/openssl_ext
<FromGitter> <Blacksmoke16> is used in the `JWT` shard
<FromGitter> <watzon> Doesn't have a way to create an RSA instance from an existing private key from what I can see. I'm trying to add that ability.
<FromGitter> <watzon> Wait, I'm using randomstate/openssl_ext
<FromGitter> <watzon> Fkuc
<FromGitter> <Blacksmoke16> rip
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
Human_G33k has quit [Quit: Leaving]
<FromGitter> <watzon> Seems like what I really need is the ability to do like python's `Crypto.PublicKey.RSA.construct` (https://pycryptodome.readthedocs.io/en/latest/src/public_key/rsa.html#Crypto.PublicKey.RSA.construct)
return0e has quit []
<FromGitter> <didactic-drunk> Or you need a blank RSA with setters for the `BIGNUM` variables.
<FromGitter> <didactic-drunk> Use https://github.com/randomstate/openssl_ext/pull/4 (https://github.com/randomstate/openssl_ext/pull/4/files) then change the loop to add setters and your done.
<FromGitter> <watzon> Ooh yeah, that could work
<FromGitter> <wout> I'm wondering, is there already a consensus about which channel we are using? Will it now be Gitter + Slack? Or will we eventually move to Slack?
<FromGitter> <tenebrousedge> there is no consensus
<FromGitter> <wout> Shouldn't someone make a choice?
<FromGitter> <wout> It's confusing to have two...
<FromGitter> <tenebrousedge> welcome to open source :/
<FromGitter> <wout> 😂️
<robacarp> oh there's a slack now?
<FromGitter> <wout> @robacarp Yes there is.
<FromGitter> <tenebrousedge> yeah, if you search you can find the invite link
<FromGitter> <tenebrousedge> oh, um search gitter that is
return0e has joined #crystal-lang
<oprypin> luckily that invite link will expire soon 😂
<jhass> what, you don't want to add slack to your bridge bot? :P
<oprypin> 😤
<oprypin> oh, turns out that emoji is named "face with look of triumph"
<oprypin> gj ruining it, apple
<jhass> seemms like the legacy name
<oprypin> jhass, what no it's not legacy, it's the name in the unicode database
<jhass> 🤷‍♂️
<oprypin> ah yes, 'SHRUG', 'ZERO WIDTH JOINER', 'MALE SIGN', 'VARIATION SELECTOR-16'
return0e has quit [Read error: Connection reset by peer]
<jhass> gotta love unicode
<oprypin> apple rolled that one out everywhere just by itself and then it just had to be added to unicode
<oprypin> u can just use 'SHRUG'
<jhass> mostly do but the combined one seemed more fitting in this context :P
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
return0e has joined #crystal-lang
<FromGitter> <didactic-drunk> > *<oprypin>* ah yes, 'SHRUG', 'ZERO WIDTH JOINER', 'MALE SIGN', 'VARIATION SELECTOR-16' ⏎ ⏎ My new dating profile.
<oprypin> 👍
Deuns has left #crystal-lang [#crystal-lang]
<raz> i made us a new chat, can never have enough of them! o/
<jhass> Does Crystal have an Instagram account yet?
<FromGitter> <j8r> Indeed jhass
<FromGitter> <j8r> You are talking about all the people called "Crystal", right? :)
<jhass> No...
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
_ht has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
* FromGitter * tenebrousedge debates how reasonable it is to have an O(n^2) macro
<FromGitter> <kinxer> `O(n^2` at compile-time?
<FromGitter> <tenebrousedge> yeah
<FromGitter> <kinxer> Huh.
<FromGitter> <kinxer> How big is `n` likely to be?
<FromGitter> <tenebrousedge> hard to guess, but probably short
<FromGitter> <tenebrousedge> small I mean
<FromGitter> <Blacksmoke16> how you manage to do that w/o recursion?
<FromGitter> <tenebrousedge> two loops
<FromGitter> <Blacksmoke16> ah
<FromGitter> <Blacksmoke16> you can also push items onto the end of an array of pseudo recursion :S
<FromGitter> <tenebrousedge> well, we'll see how ugly this ends up being
<jhass> you guys realize I have a macro that generates 10 thousands of lines of code, right? Can't get worse :P
<jhass> actually probably well above 100k, nevert measured
<FromGitter> <tenebrousedge> I didn't, but my concern is probably more that it might not be accurate rather than that it might be slow
<FromGitter> <Blacksmoke16> its my pride and joy atm 😆
<FromGitter> <Blacksmoke16> resolves dependencies between various types based on annotation values and type restrictions
<FromGitter> <Blacksmoke16> then adds them as ivars within the container class
<jhass> yeah, mine's only a pesky 5 lines I guess https://github.com/jhass/crystal-gobject/blob/master/src/gobject.cr#L8-L14
<raz> what would be a use-case?
<FromGitter> <Blacksmoke16> `run` based macro, fancy :p
<FromGitter> <Blacksmoke16> never really thought about that
<jhass> maybe I should start to use some templating...
<FromGitter> <Blacksmoke16> prob wouldnt be a bad idea :p
<FromGitter> <Blacksmoke16> raz: usecase for what?
<raz> for the thing you posted
<FromGitter> <Blacksmoke16> DI service container
<raz> the last time i heard dependency injection was in java
<FromGitter> <Blacksmoke16> fair bit of languages use the concept
<FromGitter> <Blacksmoke16> maybe not built in tho
<raz> yea but what do i use it for?
<raz> explain like i'm from marketing
<FromGitter> <tenebrousedge> often, DI makes code easier to test
<FromGitter> <Blacksmoke16> yea, it allows you to focus on building against interfaces versus concrete types.
<raz> hum ok
<FromGitter> <Blacksmoke16> and support easily swapping out functionality of a type
<raz> maybe i'll get it when i see it in action
<FromGitter> <Blacksmoke16> https://dev.to/blacksmoke16/dependency-injection-in-crystal-2d66#plug-and-play example needs updated for new version, but is the general idea
<FromGitter> <Blacksmoke16> esp some of the articles at the top might help
<raz> hum, i use mock classes for testing all the time, but never needed something extra (they'd just have the same interface as the regular class)
<jhass> heh, and there I thought the entire point of DI is that the class does not decide which concrete implementation it gets but instead an external provider does
<FromGitter> <Blacksmoke16> thats the jist of it for testing yea, the container just abstracts where those dependencies come from
<raz> hm ah i see. yea true, i guess i usually have it always in a way where the "class that does the work" gets passed in as an argument anyway
<FromGitter> <tenebrousedge> yes, that's another way to do DI
<FromGitter> <Blacksmoke16> factory versus container type of deal
<FromGitter> <Blacksmoke16> similar idea tho
<jhass> in your blog example I don't see the benefit to @writer : Writer = S3Writer.new
<jhass> def initialize(..that..) I mean of course
<FromGitter> <Blacksmoke16> just means the worker is now tightly coupled to the S3Writer
<FromGitter> <Blacksmoke16> versus being more so based on the writer interface
<jhass> > If we wanted to make the worker write to Redis instead, just change `s3_writer` to `redis_writer` and done.
<jhass> talking about this part
<jhass> IMO worker shouldn't make that decision but an external dependency tree/provider or whatever should.
<jhass> so given that mechanic I don't see how it's any less coupled
<jhass> but that's essentially why for example dagger goes through all this incomprehensible mess of modules, components and subcomponents
<FromGitter> <Blacksmoke16> how wouldnt it be less coupled? its coupled to the interface, the class is determining which instance of the writer is injected hto
<FromGitter> <Blacksmoke16> the new version allows defining like aliases to the interface, i.e. like a default implemention if typed to the interface
<jhass> how is def initialize(@writer : Writer = S3Writer.new) any more coupled?
<FromGitter> <Blacksmoke16> thats also a fine approach
<FromGitter> <Blacksmoke16> there deff isnt only one way to do this sort of thing
<FromGitter> <Blacksmoke16> nor is there one best one size fits all solution
<jhass> that's all I was trying to say with "I see no benefit to" :)
<FromGitter> <Blacksmoke16> i find it pretty cool, i use it for athena and is quite slick
<FromGitter> <Blacksmoke16> keeps everything decoupled and allows for easily registering new stuff like listeners and what not
renich has joined #crystal-lang
renich has quit [Quit: renich]
renich has joined #crystal-lang
hightower2 has quit [Remote host closed the connection]
hightower2 has joined #crystal-lang
DTZUZU2 is now known as DTZUZU
<FromGitter> <mattrberry> Hey, I saw some recent posts about this, but I'm still a little confused. I'm trying to install CrSFML, and I'm running into the issue `Missing "v2.2.0:shard.yml" for "crsfml"` while installing. I have SFML 2.5.1 installed, and I believe I've set the necessary environment vars. Is there something else I'm missing?
<FromGitter> <Blacksmoke16> Try pinning the version
<FromGitter> <Blacksmoke16> Issue is fixed for next shards release iirc
<FromGitter> <mattrberry> Sorry, could you please elaborate? Should I install a different version of shards?
<FromGitter> <Blacksmoke16> like are you specifying a version?
<FromGitter> <mattrberry> A version of what? shards? crsfml?
<FromGitter> <Blacksmoke16> ```dependencies: ⏎ crsfml: ⏎ github: oprypin/crsfml ⏎ version: 2.5.1``` [https://gitter.im/crystal-lang/crystal?at=5eaa00360b23797ec050ea3b]
<FromGitter> <mattrberry> Ahhhhh
<FromGitter> <mattrberry> Thanks a lot!
<oprypin> dang it, that bug in shards is tarnishing my project in the popular days
<oprypin> why do they not release a new one
<FromGitter> <Blacksmoke16> *soon*
<FromGitter> <Blacksmoke16> could probably go back and fix it
<FromGitter> <Blacksmoke16> er nvm
<oprypin> 🤔
<FromGitter> <Blacksmoke16> imagine it would go out with `0.35.0`
<FromGitter> <Blacksmoke16> which out to be soon id imagine
<FromGitter> <Blacksmoke16> ought
alexherbo2 has quit [Ping timeout: 240 seconds]
renich has quit [Quit: renich]
<FromGitter> <jwaldrip> is there an issue with shards resolving versions right now?
<oprypin> yea
<oprypin> shards 0.9.0 is bad
<FromGitter> <Blacksmoke16> not in the latest version
<FromGitter> <Blacksmoke16> `0.10.0`
<oprypin> wait, i forgot which onoe is bad
<FromGitter> <Blacksmoke16> the last one
<oprypin> 0.10.0 is bad, ok nvm
<oprypin> arch still doesnt have 0.10.0, huh
<FromGitter> <jwaldrip> 1) 10.0 shipped with 0.34.0 right?
<FromGitter> <Blacksmoke16> no `0.10.0` is good
<FromGitter> <Blacksmoke16> `0.9.0` is bad
<FromGitter> <jwaldrip> ```❯ shards --version ⏎ Shards 0.10.0 (2020-04-06)``` [https://gitter.im/crystal-lang/crystal?at=5eaa070097338850a2d9760b]
<FromGitter> <Blacksmoke16> so you're good
<FromGitter> <jwaldrip> sweet
<oprypin> Blacksmoke16, i'm pretty sure 0.10.0 is bad.
<oprypin> im sure, yes
<FromGitter> <Blacksmoke16> im pretty sure its not
<FromGitter> <Blacksmoke16> at least https://github.com/crystal-lang/shards/issues/303 doesnt happen anymore
<oprypin> Blacksmoke16, https://bpaste.net/C67A ???
<FromGitter> <Blacksmoke16> yea but thats easily worked around
<FromGitter> <Blacksmoke16> compared to, totally broken and cant resolve anything
<oprypin> but thats what @jwaldrip is asking
<oprypin> never had any problems with 0.9.0
<FromGitter> <Blacksmoke16> and its not really a problem with shards that didnt forget a `shard.yml` 😉
<oprypin> Blacksmoke16, wtf man
<oprypin> my project predates shards
<FromGitter> <Blacksmoke16> all good, just pulling your leg
<oprypin> consider it pulled
<oprypin> is there any way in ECR to declare a struct or a constant
<FromGitter> <Blacksmoke16> declare one?
<FromGitter> <ImAHopelessDev_gitlab> playground down or just me?
<oprypin> just u
<FromGitter> <ImAHopelessDev_gitlab> ty, workin now
<FromGitter> <Blacksmoke16> and oprypin im pretty sure `0.9.0` never really got released
<FromGitter> <Blacksmoke16> i.e. crystal still was shipping with `0.8.1`
<FromGitter> <jwaldrip> Does `shards build --production` build in release mode?
<FromGitter> <Blacksmoke16> yes
<FromGitter> <jwaldrip> Thought so
<FromGitter> <jwaldrip> actually... it doesnt!
<FromGitter> <jwaldrip> the release flag is not set
<FromGitter> <Blacksmoke16> it does
<FromGitter> <jwaldrip> ```{% unless flag?(:release) %} ⏎ raise "not in release ⏎ {% end %}``` [https://gitter.im/crystal-lang/crystal?at=5eaa09e0347bd6163045ed05]
<FromGitter> <jwaldrip> put that in a file and check
<FromGitter> <jwaldrip> I had to do `shards build --production --release` to get past it
<FromGitter> <jwaldrip> So `--production` doesn't include dev deps
<FromGitter> <jwaldrip> and `--release` does the release mode in crystal
<FromGitter> <jwaldrip> as you can see in: https://github.com/crystal-lang/shards/blob/master/src/commands/build.cr the release flags are not added to the crystal compiler
<FromGitter> <Blacksmoke16> huh
<FromGitter> <Blacksmoke16> id maybe make an issue about it
<FromGitter> <Blacksmoke16> id expect release to be passed when building with prod flag
<oprypin> well maybe you'd *expect*
<oprypin> but the intention, of course, is --no-development
<FromGitter> <Blacksmoke16> Help message does say, runs in release mode
<oprypin> :o
<oprypin> yea wow
<FromGitter> <Blacksmoke16> Plus why would you not want release mode when building production binaries
<FromGitter> <jwaldrip> yep. but clearly doesnt
<FromGitter> <Blacksmoke16> Id maybe an issue about it
<FromGitter> <Blacksmoke16> Make
<FromGitter> <tenebrousedge> @jwaldrip why are you checking for the release flag?
<FromGitter> <tenebrousedge> > _> `Error: undefined method 'new' for Int32`
<FromGitter> <j8r> @tenebrousedge A value is needed
<FromGitter> <tenebrousedge> it is being passed a value <_<
<FromGitter> <asterite> . class. new
<FromGitter> <tenebrousedge> kk thanks