RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.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
<jsn-> https://gist.github.com/jsn/7141dfb19be7d21da17bbc7614ae0b88 -- this one seems illuminating :)
<jsn-> oops, no
<hightower4> hehe nice trick with head instead of echo; cat
<FromGitter> <jwoertink> Is there a way to reference methods defined in a global scope by some global scoped namespace?
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a7ce6417084124a3454015b]
<FromGitter> <jwoertink> something like this^
<hightower4> jwoertink you can call ::x()
<FromGitter> <jwoertink> oh, that works on methods too?
<FromGitter> <jwoertink> sweet
<hightower4> jsn-, no idea what to think of that gist :)
qard has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
qard has quit [Client Quit]
<jsn-> hightower4, magic! maybe this one will be a bit more helpful: https://gist.github.com/jsn/65cb151969783eaea19bae2453cf2173
<jsn-> i suppose declarations are available immediately after parsing, init blocks are called at the "execution time" of the first require, except when they are needed earlier :)
jnyw has joined #crystal-lang
<jsn-> https://gist.github.com/jsn/2c33727b1e204038c807b1ec2c7cdb62 -- and this, i think, may even be a bug: in z.cr, "Q = q()" line actually should be executed (for side effects), but since Q value is never used, it isn't
qard has joined #crystal-lang
hightower4 has quit [Ping timeout: 240 seconds]
<Papierkorb> jsn-: Speaking in C terms, a Crystal constant is basically this: `static int Q() { static int v = q(); return v; }`. Not even sure if yours is an actual bug or not
Papierkorb is now known as Papierkorb_
Papierkorb_ is now known as Papierkorb
<Papierkorb> Considering this sample https://play.crystal-lang.org/#/r/3je6 which would fail if it was actually lazily-initialized like the C snippet
<jsn-> it's a bug since it does something unexpected and hard to document; specifically, it means that having init blocks for side effects is okay, except when they initialize an unused constant (but not, for example, an unused var)
<Papierkorb> It could be argued that the initialization of a constant should not have visible side-effects
<jsn-> it sure can; doesn't change the fact that it's misleading. reading "Q = q()" in someone else's code should give you an idea about what's going on, without remembering that side effects in constant initialization are bad (and in e.g. unused vars it still works)
greengriminal has joined #crystal-lang
DTZUZO has joined #crystal-lang
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
<FromGitter> <stevensonmt> @asterite You are correct. Thanks. Thanks also @sdogruyol for raising the idea.
greengriminal has joined #crystal-lang
woodruffw has quit [Quit: And then he took off.]
faustinoaq has joined #crystal-lang
vivus has quit [Quit: Leaving]
woodruffw has joined #crystal-lang
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
jnyw has quit [Quit: WeeChat 2.0.1]
faustinoaq has quit [Quit: IRC client terminated!]
faustinoaq has joined #crystal-lang
LastWhisper____ has joined #crystal-lang
qard has joined #crystal-lang
qard has quit [Ping timeout: 260 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
alex`` has joined #crystal-lang
hightower4 has joined #crystal-lang
illy_ has joined #crystal-lang
illy_ is now known as illy
illy is now known as _illy_
greengriminal has quit [Quit: This computer has gone to sleep]
_illy_ has quit [Quit: Leaving]
faustinoaq has quit [Quit: IRC client terminated!]
alex`` has quit [Ping timeout: 276 seconds]
<FromGitter> <stevensonmt> I have the following hash structure: ⏎ `myHash = { key => [ {int => int}, int, int, string ] }` ⏎ and I want to access the hash with `myHash.fetch(key).at(0)` and then map that result with ⏎ ⏎ ```{ |k,v| array1[v] + array2[k] }``` ... [https://gitter.im/crystal-lang/crystal?at=5a7d338de217167e2c6009f8]
rohitpaulk has joined #crystal-lang
<FromGitter> <bew> Don't use a Hash for this
<FromGitter> <bew> Sorry, maybe the Hash is ok, the Array looks misused though
<FromGitter> <stevensonmt> use a named tuple instead?
<FromGitter> <bew> What is the structure of the value of the hash?
<FromGitter> <stevensonmt> the hash nested in the array? its { int => int}
<FromGitter> <bew> No the array itself, why is there a hash inside it, then just numbers?
<FromGitter> <bew> Nulber & string sry
<FromGitter> <bew> Do you realize that Array's elements type is `Hash(Int32, Int32) | Int32 | String`?
<FromGitter> <stevensonmt> Oh, sorry. The array consists of first a hash that ultimately matches keys as indexes to another array and values as indexes to a third array.
<FromGitter> <stevensonmt> Yes, that is what I intended.
<FromGitter> <stevensonmt> To clarify this was initially in a ruby project.
<FromGitter> <bew> when you do `your_array.at(0)`, the type of the result is also `Hash(Int32, Int32) | Int32 | String`, the compiler can't know that the first element is the hash and the other are `Int32 | String`
<FromGitter> <stevensonmt> I've got a list of medications that form the key to the outside hash. The nested `Hash(Int32, Int32)` provides a way to reference the mechanism and strength of that mechanism for each med. Each med can have multiple mechanisms but always at least one.
<FromGitter> <stevensonmt> I see.
<FromGitter> <bew> and what are the Int32 or String for in the rest of the array?
<FromGitter> <stevensonmt> What if use a named tuple like: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a7d37406117191e61134f95]
<FromGitter> <bew> could work, but I strongly recommend you to make a class with the the drug data instead
<paleorange_h> somebody port this to crystal https://github.com/lc-soft/LCUI
<FromGitter> <stevensonmt> as opposed to storing it as a constant in this way?
<paleorange_h> also my issue is still not solved
<FromGitter> <bew> @stevensonmt hmm if it's constant and known at compile-time then maybe it's ok
<FromGitter> <stevensonmt> Yeah, it's just for a subset of medications that aren't going to be expanded (or at least not very often).
danielpclark has joined #crystal-lang
hightower4 has quit [Ping timeout: 256 seconds]
sz0 has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<paleorange_h> :(
alex`` has joined #crystal-lang
<FromGitter> <alehander42> @paleorange_h honestly, if you want to write your own language, writing a simple parser library (e.g. using parser combinators) might be a good beginning
<paleorange_h> yet i need a lexer/parser generator for that
<FromGitter> <alehander42> that's what I am saying, you can write this lexer/parser manually (or write a parser generator yourself), it's not very hard
<FromGitter> <sdogruyol> paleoragen_h http://crystalshards.xyz/?filter=parser
bijan__ has joined #crystal-lang
bijan__ has quit [Client Quit]
hightower4 has joined #crystal-lang
bijan__ has joined #crystal-lang
livcd has quit [Changing host]
livcd has joined #crystal-lang
<paleorange_h> oh come on, http://crystalshards.xyz/?filter=parser_generator i assumed there were none
<paleorange_h> last commit dates tho
faustinoaq has joined #crystal-lang
<FromGitter> <sdogruyol> I'm sure there were other well maintained ones
<FromGitter> <sdogruyol> let me check
<FromGitter> <sdogruyol> there you go https://github.com/ziprandom/cltk paleorange_h
DTZUZO has quit [Ping timeout: 256 seconds]
<dragonkh> hey - I saw some discussion of alias_method - but it seems to be gone now - is there currently any alias_method like thing in Crystal?
<dragonkh> I want to call a method by two names and not define the method twice - is this possible?
<dragonkh> guess not
<dragonkh> maybe this would be interesting: def name1, name2 ; do something ; end - then you can call it by either name1 or name2
<lvmbdv> closest thing i know is assigning a method as a proc, to another name
<dragonkh> thanks :) :)
bijan__ is now known as bijan_awaaaay
bijan_awaaaay has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
<lvmbdv> On another note, I would appreciate a review on my PR -> https://github.com/crystal-lang/crystal/pull/5676
<lvmbdv> Because I doubt homebrew will fix that stuff any time soon :^)
<FromGitter> <straight-shoota> drangonkh Crystal tries to avoid aliases because they don't add anything, it's just another name to remember
<dragonkh> ok - fair point
<txdv> 1
<RX14> @lvmbdv, they probably will fix it
<RX14> someone just needs to send a PR with a wrapper script for crystal that calls brew to set LD_LIBRARY_PATH and friends
<RX14> "The best solution would be to write a wrapper script that calls your desired configuration yourself."
<RX14> so what I recommended
<lvmbdv> you mean the wrapper script will reside on crystal?
<RX14> in the homebrew formula
<lvmbdv> okay then, that might happen
<RX14> but check the github issue
<lvmbdv> which one
<RX14> yours
<lvmbdv> cool
avdi has quit []
avdi has joined #crystal-lang
hightower3 has joined #crystal-lang
hightower2 has quit [Ping timeout: 276 seconds]
faustinoaq has quit [Quit: IRC client terminated!]
rohitpaulk has quit [Remote host closed the connection]
<lvmbdv> thanks RX14 my phone usually notifies me about the latest comments but it died apparently
rohitpaulk has joined #crystal-lang
moei has joined #crystal-lang
manveru has quit []
manveru has joined #crystal-lang
greengriminal has joined #crystal-lang
bijan__ has joined #crystal-lang
bijan__ has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
rohitpaulk has quit [Ping timeout: 256 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
rohitpaulk has joined #crystal-lang
danzilio has quit []
danzilio has joined #crystal-lang
greengriminal has joined #crystal-lang
greengriminal has quit [Remote host closed the connection]
codenoid has joined #crystal-lang
codenoid has left #crystal-lang [#crystal-lang]
maattdd has joined #crystal-lang
snsei has joined #crystal-lang
Poeticold is now known as Poeticode
LastWhisper____ has joined #crystal-lang
bijan__ has joined #crystal-lang
bijan__ is now known as bijan_awaaaay
bijan_awaaaay is now known as bijan__
maattdd has quit [Ping timeout: 240 seconds]
maattdd has joined #crystal-lang
bijan__ has quit [Quit: Textual IRC Client: www.textualapp.com]
bijan_ has joined #crystal-lang
woodruffw has quit [Ping timeout: 265 seconds]
<FromGitter> <aisrael> @RX14 You’re right. Go dep mgt is (or lack thereof) is bird brained
<RX14> It was clearly built for googles monorepo
<RX14> Which is cool
<RX14> But when you release it outside of Google you have to fix that
<RX14> And they haven't and its insane
woodruffw has joined #crystal-lang
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
duane has joined #crystal-lang
<FromGitter> <sdogruyol> bird brained, lol
<FromGitter> <sdogruyol> Google pretty much don't give a damn about anyone else
greengriminal has joined #crystal-lang
<FromGitter> <sdogruyol> if you ask them, they run the world...
<FromGitter> <malyutinegor> Hello!
<FromGitter> <sdogruyol> hi @malyutinegor
<FromGitter> <r00ster91> hello
<FromGitter> <malyutinegor> I'm learning Crystal.
<FromGitter> <r00ster91> oh thats great
<FromGitter> <sdogruyol> that's great, welcome @malyutinegor 👍
<FromGitter> <malyutinegor> Is there some zeroconf lib or another thing for finding services in network?
<FromGitter> <malyutinegor> Thanks.
<FromGitter> <sdogruyol> I'm not sure what zeroncof is..
<FromGitter> <sdogruyol> zeroconf*
bijan_ has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
bijan_ has joined #crystal-lang
bijan_ has quit [Client Quit]
bijan_ has joined #crystal-lang
<FromGitter> <malyutinegor> I'm too 😄
bijan_ has quit [Quit: My iMac has gone to sleep. ZZZzzz…]
bijan_ has joined #crystal-lang
greengriminal has quit [Quit: This computer has gone to sleep]
snsei has quit [Remote host closed the connection]
greengriminal has joined #crystal-lang
bijan_ is now known as bijan_awaaaay
rohitpaulk has quit [Remote host closed the connection]
bijan_awaaaay has quit [Quit: System has gone to sleep. ZZZzzz…]
maattdd has quit [Ping timeout: 256 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
rohitpaulk has joined #crystal-lang
return0e has joined #crystal-lang
return0e_ has quit [Read error: No route to host]
<FromGitter> <stevensonmt> Having trouble getting kemal to render a partial view. In `src/views/main.ecr` I have the line `<%= render "./views/partial.ecr" %>` but I keep getting a `file not found` error.
rohitpaulk has quit [Ping timeout: 248 seconds]
<FromGitter> <stevensonmt> Should the path instead be `./partial.ecr`?
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <sdogruyol> it should be `src/views/partial.ecr`
<FromGitter> <eliasjpr> Heads up, ⏎ ⏎ The Amber Framework team has assume maintenance responsibilities for the Micrate crystal shard. As we want to support the crystal community we will maintain Micrate as a complete separate shard. We will monitor and address issues in order of community importance, Welcome people to contribute as well. ⏎ ⏎ @juanedi as the author of the shard we will listen closely and take good
<FromGitter> ... consideration to his suggestions. Thank you for the hard work @juanedi. ... [https://gitter.im/crystal-lang/crystal?at=5a7dd5c1b3c4a0d376015dfd]
<FromGitter> <stevensonmt> @sdogruyol I think @malyutinegor is talking about zero configuration network service discovery. Basically plug and play for any device connecting to a network. Something like this go pkg https://github.com/grandcat/zeroconf. I don't think there is a similar package in crystal.
<FromGitter> <sdogruyol> thank you @stevensonmt
<FromGitter> <stevensonmt> @eliasjpr the readme has two sections with instructions for adding `micrate` to dependencies, but in the first instance it is `github: amberframework/micrate` and in the second it is `github: juanedi/micrate`
<FromGitter> <eliasjpr> Working on it. Thanks :)
<FromGitter> <stevensonmt> thanks @sdogruyol. I probably have some other bug then b/c I think I tried that. Will try again when I get home.
Ven`` has joined #crystal-lang
maattdd has joined #crystal-lang
faustinoaq has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.0.1]
hightower4 has quit [Ping timeout: 276 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
faustinoaq has quit [Ping timeout: 248 seconds]
hightower4 has joined #crystal-lang
maattdd has quit [Ping timeout: 240 seconds]
<FromGitter> <xfbs> Hey guys, just wondering but is there a layout engine in crystal?
<FromGitter> <straight-shoota> what do you mean with layout engine?
<FromGitter> <xfbs> I don't really know what I mean haha. You know how in jekyll, or for example in rails, you can define layouts (views) in like a DSL, something like that? I don't need it to be turing complete, just looking what's out there, so I don't end up implementing something that already exists :p
<hightower4> xfbs: HTML-based views?
<crystal-gh> [crystal] straight-shoota opened pull request #5697: Add JSON::Serializable and YAML::Serializable (master...jm/feature/serializable) https://git.io/vAIFr
<FromGitter> <straight-shoota> https://github.com/straight-shoota/crinja has layouts
<FromGitter> <straight-shoota> it's not a DSL but HTML templates similar to Jekyll with a powerful template engine
<FromGitter> <straight-shoota> besides that, you can take a look at other template engines: https://github.com/veelenga/awesome-crystal#template-engine though I'm not sure any of the others supports layouts out of the box
Ven` has joined #crystal-lang
Ven`` has quit [Ping timeout: 248 seconds]
<FromGitter> <xfbs> Ahh I think that's what I'm looking for, merci :)
Ven` has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
greengriminal has quit [Quit: Leaving]
alex`` has joined #crystal-lang
alex`` is now known as alexherbo2
alexherbo2 is now known as alex``
bijan_ has joined #crystal-lang
imonmyown has joined #crystal-lang
imonmyown has quit [Ping timeout: 260 seconds]
bijan_ has quit [Quit: System has gone to sleep. ZZZzzz…]
faustinoaq has joined #crystal-lang
<RX14> @xfbs they're typically called templating engines
<RX14> because they generate HTML
<RX14> the browser does the actual layout
<FromGitter> <straight-shoota> it seemes he meant having a general layout for html files and using that when rendering individual pages as a base
kochev has joined #crystal-lang
alex`` has quit [Ping timeout: 256 seconds]
kochev has quit [Ping timeout: 260 seconds]
faustinoaq has quit [Ping timeout: 268 seconds]
<FromGitter> <xfbs> I don't really know what I'm doing lol
<FromGitter> <xfbs> Btw, does crystal support Regexes in case expressions? Like ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a7e192593be87284d99ee40]
<FromGitter> <xfbs> Docs suggest no, but just to be sure I thought I'd ask
<FromGitter> <straight-shoota> yes of course
<FromGitter> <straight-shoota> ```if /foo/ === a ⏎ end``` ⏎ ⏎ and `===`operator matches a string with a regex [https://gitter.im/crystal-lang/crystal?at=5a7e1a0b93be87284d99f3ed]
<FromGitter> <xfbs> Ahh, see I thought this would work :p Why couldn't I find it in the docs tho?
<FromGitter> <xfbs> Should someone (me) add it someone? I think this is super useful
<FromGitter> <bew> It pretty well documented here https://crystal-lang.org/docs/syntax_and_semantics/case.html
<FromGitter> <bew> No?
andersh has quit []
andersh has joined #crystal-lang
greengriminal has joined #crystal-lang
railgun has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 256 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
duane has quit [Ping timeout: 268 seconds]
<crystal-gh> [crystal] straight-shoota opened pull request #5699: Fix YAML::Core parse float with leading 0 or . (master...jm/fix/5698) https://git.io/vAL8q
moei has quit [Quit: Leaving...]
<FromGitter> <xfbs> Oh well, I mean like, just the feature that you can use regexes in `when xx` expressions wasn't immediately clear, I think that's a big seller!
<FromGitter> <xfbs> Also another question: when I have `a: String | Nil`, and I want to call `.to_i` on the `String`, how can I do this?
<Papierkorb> xfbs, what should the result be if it's nil?
<FromGitter> <xfbs> Still `nil`. Like "call .to_i if !obj.nil?, do nothing otherwise"
<Papierkorb> Object#try, combine with the &. shorthand notation
<FromGitter> <xfbs> Ahh, I knew there was something. Gotcha!
cremes has quit [Quit: cremes]
<FromGitter> <jwoertink> Is there a way with specs where I could run something when the entire spec suite is done?
<RX14> @jwoertink at_exit
<RX14> lol
cremes has joined #crystal-lang
cremes has quit [Client Quit]
bijan_ has joined #crystal-lang