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
<FromGitter> <paulcsmith> That did it!! Thanks again
<FromGitter> <Blacksmoke16> mhm
kotrcka has joined #crystal-lang
adam12 has left #crystal-lang [#crystal-lang]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #crystal-lang
<sagax> hi all!
<sagax> crystal very awesome
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <smalls12> was on the crystal landing page, specifically on install ( https://crystal-lang.org/install/ ) and noticed that if you click the rotating crystal in the top left, it just freezes and stops rotating
<FromGitter> <smalls12> should it redirect to homepage?
<FromGitter> <smalls12> ( just a funny quirk )
ur5us has quit [Ping timeout: 250 seconds]
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
lanodan has quit [Ping timeout: 240 seconds]
lanodan has joined #crystal-lang
_ht has joined #crystal-lang
<FromGitter> <naqvis> that allows to use mouse-up/down to rotate the crystal
<FromGitter> <3n-k1> is it possible to read a class' annotations from a different macro/function? something like this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e8c1f61d021c45cc7cc8c0d]
rohitpaulk has joined #crystal-lang
<FromGitter> <3n-k1> ah, it was `{{c.resolve.annotation(MyAnnotation)}}`
rohitpaulk has quit [Ping timeout: 260 seconds]
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
<FromGitter> <3n-k1> does `Class.instance_vars` not work? This code is printing an empty array ⏎ ⏎ ```class Options ⏎ @temp : String? ⏎ end ⏎ ⏎ puts {{Options.instance_vars.stringify}}``` [https://gitter.im/crystal-lang/crystal?at=5e8c268a5b98016d6a1c36a7]
<FromGitter> <3n-k1> oh i'm using it wrong
<FromGitter> <3n-k1> okay, so is there something like `methods` but for the class and instance variables?
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
<FromGitter> <3n-k1> how do I use `instance_vars`?
<FromGitter> <naqvis> what is your use-case? or what is it you are trying to achieve?
<FromGitter> <3n-k1> just screwing around. found a github issue, realized it only works in methods, not `finished`
return0e_ has joined #crystal-lang
<FromGitter> <3n-k1> which is interesting because finished can call that method /shrug
DeBot has quit [Ping timeout: 246 seconds]
return0e has quit [Ping timeout: 250 seconds]
deavmi has joined #crystal-lang
davic has quit [Excess Flood]
<Subsentient> How do I perform a narrowing integer cast in Crystal?
<oprypin> Subsentient: that.to_i16
<Subsentient> oprypin: So it's a method, there's no cast operator?
<oprypin> why do u want an operator specifically
<oprypin> there's a universal wrapper too. Int16.new(that)
<oprypin> not sure if that might have changed with the overflow handling. maybe it needs to be new! if u want to truncate instead of erroring on overflow
<FromGitter> <naqvis> to avoid overflow use bang! operator `that.to_i16!`
deavmi has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
deavmi has joined #crystal-lang
<Subsentient> The problem I'm having is converting a UTF-32 Char to 7-bit ASCII. I know the character will always only be 7-bit. I want to convert a Char to UInt8
<Subsentient> Without checking for overflow
<Subsentient> I get "Invalid integer" when invoking e.g. 'h'.to_u8
<Subsentient> In C I'd just do (char)L'h' and that'd be the end of it
return0e has joined #crystal-lang
<raz> crystal 0.34 has been out for multiple hours but homebrew still points to 0.33
* raz is deeply disappoint
<raz> on a more serious note :P - how do you guys keep your crystal on osx? with homebrew or one of the version mgrs?
return0e_ has quit [Ping timeout: 258 seconds]
ur5us has joined #crystal-lang
<Subsentient> So nobody knows how to convert a Char to a UInt8 unconditionally?
<Subsentient> Short of endian-dependent bit fiddling?
<oprypin> Subsentient: you have been told how in 2 ways by 2 people
<Subsentient> oprypin: Both of those ways throw a runtime exception
<oprypin> raz: homebrew updates at its own pace manually
<oprypin> Subsentient: look for "!" in the messages that's the key
<raz> oprypin: yup i know. wasn't entirely serious, just eager to try out the new shards (sounds like it got a speed boost) :)
<Subsentient> Nope, no dice
Human_G33k has joined #crystal-lang
<oprypin> raz: i just have a Crystal repo and alias cr=path/to/repo/bin/crystal
<oprypin> and in there u `git pull` and make. no need to even wait for release
<raz> hmmm i see
davic has joined #crystal-lang
HumanG33k has quit [Ping timeout: 256 seconds]
<Subsentient> oprypin: As you can see, the prescribed methods do not exist
<oprypin> Subsentient: u first need Char.ord
<oprypin> a character is not a number
<Subsentient> Ahh, so it's not an integer type at all?
<oprypin> it's not
<Subsentient> okay, that makes more sense
<oprypin> the fact that it's implemented as int32 is not too hidden tho
<Subsentient> Yeah, that's what I was going by
<Subsentient> used to C/C++ where chars are a primitive type
<oprypin> Subsentient: but if u claim that it's always 7 bit then how can .to_u8 overflow?
<Subsentient> That's a good question, I'm literally feeding it a character literal and getting an overflow.
<yxhuvud> Perhaps every char needs to be split in 4?
<oprypin> nono
<oprypin> Subsentient: oh lol right
<oprypin> it's behaving looks a string not like a number
<oprypin> '9'.to_u8 == 9_u8
<oprypin> like*
<yxhuvud> oh right, so missing `.ord`, again
<FromGitter> <naqvis> raz Brian has already submitted the PR#52644 (https://github.com/Homebrew/homebrew-core/pull/52644) and awaiting merge on HomeBrew
<raz> naqvis: :partyparrot:
ur5us has quit [Ping timeout: 260 seconds]
<FromGitter> <naqvis> 👍
deavmi has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
deavmi has joined #crystal-lang
ur5us has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
travis-ci has joined #crystal-lang
<travis-ci> crystal-lang/crystal#62b5d52 (master - Merge pull request #9012 from crystal-lang/ci/update): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/672002237
travis-ci has left #crystal-lang [#crystal-lang]
ur5us has quit [Ping timeout: 260 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 265 seconds]
rohitpaulk has joined #crystal-lang
deavmi has quit [Quit: https://quassel-irc.org - Chat comfortably. Anywhere.]
deavmi has joined #crystal-lang
yxhuvud has quit [Read error: Connection reset by peer]
yxhuvud has joined #crystal-lang
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<FromGitter> <smalls12> > that allows to use mouse-up/down to rotate the crystal ⏎ ⏎ oh that makes sense : )
<FromGitter> <Blacksmoke16> @3n-k1 you can also just use the class type directly like `{{Options.annotation(MyAnnotation)}}`
<FromGitter> <faustinoaq> Wow, @naqvis just published https://github.com/naqvis/crystal-odbc Amazing! 🎉 MSSQL here we go 🚀
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
<FromGitter> <naqvis> 🎉
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
Subsentient has quit [Ping timeout: 260 seconds]
<FromGitter> <ImAHopelessDev_gitlab> hello
<FromGitter> <ImAHopelessDev_gitlab> how is everyone doing
_ht has quit [Quit: _ht]
_ht has joined #crystal-lang
_ht has quit [Client Quit]
<FromGitter> <naqvis> hi Girng, so far so good. how are you doing?
_ht has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> Good ty
Subsentient has joined #crystal-lang
postmodern has joined #crystal-lang
<FromGitter> <faustinoaq> @ImAHopelessDev_gitlab Working from Home is better than I though 😁
ur5us has joined #crystal-lang
darkstardev13 has quit [Read error: Connection reset by peer]
darkstardev13 has joined #crystal-lang
<repo> Blacksmoke16: hey, how would i set the status code for a response in athena?
<repo> not an error code but in this case 201 - CREATED
<FromGitter> <Blacksmoke16> with a JSON response, or empty response body?
<FromGitter> <Blacksmoke16> would be like `Response.new status: :accepted`
<FromGitter> <Blacksmoke16> or `Response.new obj.to_json, status: :accepted`
<FromGitter> <Blacksmoke16> er sorry, `:created`
_ht has quit [Quit: _ht]
blassin has joined #crystal-lang
<blassin> hello all
<blassin> is there any way to have "partials" in ECR templates?
<FromGitter> <Blacksmoke16> not afaik
<blassin> I have a template with <%= render_partial "home.ecr %> but then when I define the `render_partial` method, I try to pass the argument I get to ECR.render but I get "undefined macro variable"
<FromGitter> <Blacksmoke16> i think you could do something like
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e8cf2649316f34b8d8888d0]
<blassin> hmm I see
<blassin> is there any other templating engine out there that supports partials?
<FromGitter> <Blacksmoke16> maybe checkout v
<FromGitter> <Blacksmoke16> https://github.com/jeromegn/kilt
<blassin> thanks, will have a look!
blassin has quit [Remote host closed the connection]
blassin has joined #crystal-lang
<blassin> @Blacksmoke16 got it to work :D
<blassin> with Kilt, using ECR templates
<blassin> private macro render_partial(name, path = "themes/default/partials") ; Kilt.render("#{{{path}}}/{{name.id}}") ; end
<blassin> thanks for the tip!
blassin has quit [Remote host closed the connection]
hightower2 has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> @faustinoaq nice ;D
<hightower2> congrats on 0.34, just seen it
<FromGitter> <ImAHopelessDev_gitlab> oh god
<FromGitter> <Blacksmoke16> 👍 nice
darkstardev13 has quit [Quit: Leaving]
darkstardev13 has joined #crystal-lang
<repo> Blacksmoke16: hm so no way to pass the object itself to Response?
<repo> would be cool if it would use to_json(response)
<repo> thus writing directly to the response socket
<FromGitter> <Blacksmoke16> iv'e been thinking about that
<repo> maybe some block variant of the Response initializer?
<FromGitter> <Blacksmoke16> i just havent been able to think of a good way for it to play nice with the listener approach
<repo> it could yield an io and only call the block when it's time to write the response body
<FromGitter> <Blacksmoke16> since as soon as we write to that, headers are locked
<repo> yeah
<FromGitter> <Blacksmoke16> can you open an issue about it so i dont forget?
<repo> sure thing
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> the other problem is the actual response obj isnt exposed anywhere atm
<FromGitter> <Blacksmoke16> > *<repo>* it could yield an io and only call the block when it's time to write the response body ⏎ ⏎ something like
<repo> Blacksmoke16: what's the current behavior if i return an object? Does it call to_json() or to_json(io)?
<repo> or even to_json(builder)
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e8d00fb9316f34b8d88a890]
<FromGitter> <Blacksmoke16> that could work well i think?
<repo> yeah, lgtm!
<FromGitter> <Blacksmoke16> 👍 cool
<FromGitter> <Blacksmoke16> when you return an object, the current logic is to dispatch a view event
<FromGitter> <Blacksmoke16> which gets picked up by https://github.com/athena-framework/athena/blob/af49acc4d2ee398d5a6b4395591be05bdbddc211/src/listeners/view_listener.cr#L28 to return the `Response` object
<FromGitter> <Blacksmoke16> and its just stored in an `IO::Memory` atm
<repo> ic
<FromGitter> <Blacksmoke16> but deff would prob switch it to use this IO callback approach
<FromGitter> <Blacksmoke16> as i would then do like
<FromGitter> <Blacksmoke16> ```def write(io : IO) : Nil ⏎ @callback.call io ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e8d01ffc52b6a38abcf2d07]
<FromGitter> <Blacksmoke16> https://github.com/athena-framework/athena/blob/af49acc4d2ee398d5a6b4395591be05bdbddc211/src/route_handler.cr#L38 ⏎ and instead of this do ⏎ `response.write context.response`
<FromGitter> <Blacksmoke16> good call on that, i really like that approach
<FromGitter> <Blacksmoke16> going to bump that macro def pr again here soon. Once thats merged it unblocks me from some stuff i want to do in DI and by extension athena itself
<repo> nice
<repo> Issue is open.
<FromGitter> <Blacksmoke16> <3 cheers
<FromGitter> <Blacksmoke16> ill get that done this week then you can upgrade to that commit if you needed
<repo> that'd be sweet! But it's a hobby project of mine, so no stress :)
<FromGitter> <Blacksmoke16> no no, is nice to finally get some actual feedback (i.e. people using it heh)
<repo> :)
<repo> it's a bit rough on the edges imho, but i really like the overall concepts. I feel that athena is the only framework that doesn't get in my way.
<FromGitter> <Blacksmoke16> id agree with that, most of the effort has gone into the core framework/loop
<FromGitter> <Blacksmoke16> that good/better abstractions could be built on
<repo> Blacksmoke16: you don't have a way to omit writing the full class name in annotations do you? I've got the same problem with JSON::Field annotations. It's annoying if you use namespaces alot, which i do. :/
<FromGitter> <Blacksmoke16> with the goal of mostly everything being decoupled and interchangeable via DI, so testing and doing custom logic is easy and just works
<repo> yeah
<FromGitter> <Blacksmoke16> thats a byproduct of crystal not having imports like ES6 or PHP `use xxx`
<FromGitter> <Blacksmoke16> either include the modules or make some aliases?
<repo> mh
<repo> i wonder if aliases defined in the class where the annotations are defined will work
<FromGitter> <Blacksmoke16> `alias RECON = Redo::Api::ParamConverters`
<FromGitter> <Blacksmoke16> `RECON::Form`
<repo> nope :/
<repo> alias Forms = Redo::Api::Forms
<repo> alias ParamConverters = Redo::Api::ParamConverters
<FromGitter> <Blacksmoke16> yea that would be the way to go
<repo> doesn't work though
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Blacksmoke16> whats the error?
<repo> at least not if defined in the class i'm defining the annotation in
<repo> Error: undefined constant Forms::Authorization
<FromGitter> <Blacksmoke16> i think youd want to define them on the top level
<FromGitter> <Blacksmoke16> or at least within your base module?
<repo> yeah...
<repo> what does kinda defeat the purpose of having namespaces in the first place :/
<FromGitter> <Blacksmoke16> ```class Redo ⏎ alias Converters = Redo::Api::ParamConverters ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5e8d0574cc370f0b07ccc8b6]
<FromGitter> <Blacksmoke16> module*
<repo> yeah
<repo> meh
<FromGitter> <Blacksmoke16> i feel you tho
* FromGitter * Blacksmoke16 wants like:
<repo> wouldn't it be nice to have javascript style imports..
<FromGitter> <Blacksmoke16> ```import Form from 'converters/form'```
<FromGitter> <Blacksmoke16> yea
<repo> yuo
<FromGitter> <Blacksmoke16> or even how PHP does it
<repo> yup
<repo> or python
<FromGitter> <Blacksmoke16> ```use Redo::Api::ParamConverters::Form; ⏎ ⏎ Form(FOO)``` [https://gitter.im/crystal-lang/crystal?at=5e8d05cd5d148a0460efdfff]
<repo> mmh
<repo> Blacksmoke16: but still, i would think it'd be possible for annotations to recognize the scope they're defined in
<FromGitter> <Blacksmoke16> only so much i can do :(
<FromGitter> <Blacksmoke16> sounds like that bug?
<repo> Blacksmoke16: hmm yeah
<repo> this could be worth a shot for "fixing" annotations in athena
<repo> wouldn't fix the problem for JSON::Serializable
<FromGitter> <Blacksmoke16> ill have to look into it
<repo> but meh
<repo> won't work if you decide to use the full name
<FromGitter> <Blacksmoke16> :/
<repo> low prio anyway :P
<repo> it has just bugged me a long time.
<FromGitter> <Blacksmoke16> maybe they'll get some improvements after 1.0
<oprypin> Stephie, i've just made the evilest evil merge in git xDDDD
<oprypin> literally merged your branch and jan_zajic's
<oprypin> not much point to it but my hope is that squash-committing the PR on github will show 3 authors at once
<Stephie> lol
<Stephie> you know that github just supports that by ammending Co-Authored-By tags to the commit message right?
<oprypin> yes but this way the actual commits will be referenced on the PR :D :D
<oprypin> oh god it works
<oprypin> both PRs have advantages, it seems nearly half and half in terms of code involved
<oprypin> (ahem one of them was not a PR)
<repo> Blacksmoke16: holy shit :D
<FromGitter> <Blacksmoke16> xD
<repo> "that was easy!"
<repo> fixed it! xD
<FromGitter> <Blacksmoke16> thoughts on dropping the `Int32` overload for response?
<FromGitter> <Blacksmoke16> given that `HTTP::Status` is a thing?
<FromGitter> <Blacksmoke16> @repo
<FromGitter> <Blacksmoke16> naw ill keep it, easy enough to support
<repo> Yeah i’d keep it for that reason
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e8d12f8c52b6a38abcf4de0]
<repo> is HTTP::Status an enum?
<FromGitter> <Blacksmoke16> yea, https://crystal-lang.org/api/master/HTTP/Status.html its in the stdlib
<FromGitter> <Blacksmoke16> is the API i got
<FromGitter> <Blacksmoke16> BC as it creates a proc and uses that overload
<FromGitter> <Blacksmoke16> but supports string, proc, and blocks
<repo> In that case i’d rather overload new with Int32 and call the other one using HTTP::Status.from_value(status_code)
<repo> prevents you from using like 9001 as a status code on compile time, no?
<FromGitter> <Blacksmoke16> it overloads the initializer to do that
<FromGitter> <Blacksmoke16> to validate its a valid code
<repo> Yeah but that’s a runtime error
<FromGitter> <Blacksmoke16> so would the other way no?
<repo> ah yeah you’re right