ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.22.0 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
Kug3lis_ has quit [Ping timeout: 240 seconds]
Kug3lis has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<crystal-gh> [crystal] will opened pull request #4333: Add FloatPrinter based on Grisu3 (master...grisu3) https://git.io/v9kXR
_whitelogger has joined #crystal-lang
unshadow has quit [Ping timeout: 260 seconds]
<FromGitter> <schoening> What happens when you try @romeroadrian ?
<FromGitter> <schoening> InitiInitial
<FromGitter> <schoening> Initial thought is you need a ssl certificate?
Kug3lis has joined #crystal-lang
Kug3lis has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
unshadow has joined #crystal-lang
unshadow has quit [Remote host closed the connection]
Kug3lis has joined #crystal-lang
mark_66 has joined #crystal-lang
Kug3lis has quit [Quit: Textual IRC Client: www.textualapp.com]
bjz has joined #crystal-lang
Qchmqs has joined #crystal-lang
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
j2k has joined #crystal-lang
j2k has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sz0 has joined #crystal-lang
A124 has quit [Ping timeout: 260 seconds]
j2k has joined #crystal-lang
j2k has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 255 seconds]
Philpax has joined #crystal-lang
Philpax_ has quit [Ping timeout: 260 seconds]
McSoFake has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
<wuehlmaus> hi, all, how can i make a method invocable on every Object, that does e.g. {{Hash.methods.map &.name.stringify}} ?
<wuehlmaus> Hash should be changeable to every Object
<Papierkorb> wuehlmaus: add the method to `Object`, then use the magic @type variable in your {{ macro }} to refer to the current type
<wuehlmaus> i tried class Object def methods {{self.methods.... but that didn't work
<wuehlmaus> that's the thing i am looking for
<wuehlmaus> well, "def methods() {{self ...."
<wuehlmaus> Papierkorb: thanks, great, it works
<RX14> wuehlmaus, i'm a bit confused by what you're trying to do
<wuehlmaus> Class.methods functionality of ruby
<wuehlmaus> crystal doesn't do the same thing
<FromGitter> <bew> and why do you need that method function?
<Papierkorb> wuehlmaus: what do you need it for?
<wuehlmaus> it's handy
<RX14> it hasn't been added to crystal because we don't have any way for that data to really be useful
<Papierkorb> wuehlmaus: for what?
<RX14> outside macros at least
<wuehlmaus> to have a list what to invoke on an object is handy to me
<RX14> why not use the documentation?
<Papierkorb> wuehlmaus: you can probably configure your text editor to tell you as you type.
<wuehlmaus> it's more dense
<RX14> I find .methods really hard to use
<RX14> first of all you have to actually execute the code you're working on
<RX14> as you're working on it
<RX14> it requires all your code to compile as you're working on it
<RX14> it's just unwieldy to me
<RX14> it takes a few secs to look up the methods in the docs
Qchmqs has quit [Ping timeout: 260 seconds]
<wuehlmaus> i use icr
<RX14> yeah it's useful in ICR I guess
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<RX14> i don't use icr as it's a massive hack
<RX14> and not really useful in the same situations as pry would be
<wuehlmaus> well, pry is a bit of state of the art. i am happy to at least HAVE icr for learning crystal.. it helps
<wuehlmaus> [me]
<RX14> yeah for learning ICR is cool
<RX14> i guess i've been using crystal for so long I didn't think of that
<wuehlmaus> lucky one! crystal is reall a joy to use. i took a look when it was mentioned on #nim, then lost track and came back last weekend. i really enjoy it!
<wuehlmaus> s/reall/really/
<RX14> cool!
<RX14> maybe ICR should add some of these methods to object...
<RX14> like .methods
<RX14> I wouldn't like it in the stdlib because it might confuse people
<RX14> but in an icr-specific prelude it would be great
<FromGitter> <bew> +1
<RX14> someone make an issue on icr i'm lazy :3
<FromGitter> <bew> it seems that every developers here are lazy
zipR4ND has joined #crystal-lang
zipR4ND has quit [Ping timeout: 255 seconds]
A124 has joined #crystal-lang
<literal> if you want volunteers to not be lazy, you need to pay them :P
<FromGitter> <drosehn> I think if you read through all the code which has been written for the crystal compiler and stdlib, it's clear that there have to be several very busy developers!
<Papierkorb> to be fair, there are paid dev's, but to be fair again, much of the crystal stuff has been written by random people in their spare time
j2k has joined #crystal-lang
unshadow has joined #crystal-lang
<unshadow> Does it makes sense that a code which compiles and run fine crashes with invalid memory when compiled with --release ?
<BlaXpirit> unshadow, not unusual
<unshadow> BlaXpirit: how should I approch this ? why would an optimized code crashes where non-optimzed works ?
<RX14> use gdb
<RX14> wait for the segfault
<RX14> then type bt to get the backtrace
<BlaXpirit> nah just add a bunch of prints and see after which one it stops lol
<BlaXpirit> those backtraces are too cryptic
<unshadow> Hm.... gdb shows this to be the issue: client = server.accept ....
<unshadow> I'll trace around to see if this is really the problematic area :\
<unshadow> Oh ... wow, it's actually crashes at the server.accept, wtf ...
<unshadow> bug in crystal 0.22 ?
zipR4ND has joined #crystal-lang
<zipR4ND> hey all, is there a possibility to split a string on a char but preserve the char, like split after it?
<FromGitter> <bew> unshadow: can you share the code that does not work?
<unshadow> bew: I'm going over it know, it seems that --release is extra peeky, I added a `if server.is_a? TCPServer` around the `client = server.accept` and it works now, it's really wierd, but... w\e
<Papierkorb> zipR4ND: use a regex: `"foo,bar".split(/(=?,)/)`
<Papierkorb> > "foo,bar".split(/(=?,)/) # => ["foo", ",", "bar"]
<Papierkorb> zipR4ND: =? is a positive look-behind
<BlaXpirit> wasnt it ?=
<BlaXpirit> yeah Papierkorb lol your regex is actually optional = then comma
<BlaXpirit> zipR4ND, "foo,bar".split(/(,)/) # => ["foo", ",", "bar"]
<BlaXpirit> "foo,bar".split(/(?<=,)/) # ["foo,", "bar"]
<Papierkorb> BlaXpirit: damn regex notation
<FromGitter> <bew> I don't understand what does split with a regex.. How can it return foo then , then bar?
<Papierkorb> it simply splits on the place(s) it matches
<Papierkorb> if it doesn't capture anything, it's like a normal string split, the matched stuff goes away
<Papierkorb> if it does capture something, the (first?) capture-group is returned as additional element in between the left and right potion of the string
<FromGitter> <bew> But why is the comma kept in the result?
<FromGitter> <bew> Ah..
<BlaXpirit> i dont get it, what's the difference? 1. https://crystal-lang.org/api/0.22.0/Enumerable.html#chunks%28%26block%3AT-%3EU%29forallU-instance-method 2. https://crystal-lang.org/api/0.22.0/Iterable.html#chunk%28reuse%3Dfalse%2C%26block%3AT-%3EU%29forallU-instance-method 3. https://crystal-lang.org/api/0.22.0/Iterator.html#chunk%28reuse%3Dfalse%2C%26block%3AT-%3EU%29forallT%2CU-instance-method
Ven has joined #crystal-lang
Ven is now known as Guest50256
bjz has joined #crystal-lang
unshadow has quit [Ping timeout: 240 seconds]
unshadow has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <bew> Indeed thoses are very similar
j2k has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Guest50256 has quit [Ping timeout: 240 seconds]
Ven_ has joined #crystal-lang
cerulean has quit [Ping timeout: 255 seconds]
<zipR4ND> @Papierkorb @BlaXpirit oh, didn't see that. yeah I now about regex, but this is not an option here :)
<Papierkorb> zipR4ND: "not an option"?
<Papierkorb> zipR4ND: Not possible with split(String) alone. You could manually re-add a dot-string between each element though..
<zipR4ND> yeah I use this in the new Scanner for cltk
<zipR4ND> trying to get away from pcre for performance reasons ..
<BlaXpirit> zipR4ND, have you actually profiled it?
<BlaXpirit> for maximal performance, this is a good general algorithm http://stackoverflow.com/a/2941193
cerulean has joined #crystal-lang
Ven_ has quit [Ping timeout: 260 seconds]
Ven has joined #crystal-lang
Ven is now known as Guest31321
<FromGitter> <thbar> Hi there - I'm trying to port https://github.com/thbar/kiba (a ruby gem) to Crystal (at least some parts of it). What is the most idiomatic way to describe a type that would be an "arbitrary hash", so in essence a Hash with arbitrary types for keys and values? (or at least a large number of types?)
<RX14> what's it used for?
<FromGitter> <thbar> Kiba is an ETL gem, in which those hashes are used as "rows of data", provided by sources & modified by transforms. So those hashes can contain whatever data the user is reading & transforming.
<FromGitter> <thbar> Example: a CSV source will read a csv file and yield rows with each header as keys (strings or symbols), then strings as values etc.
<FromGitter> <thbar> but then a given "transform" may take that as an input, and add an arbitrary key (string/symbol) with a `Float` value etc
<FromGitter> <thbar> I do think some form of "recursive alias" is probably the way to go, but unsure if this is the correct way to handle that.
Guest31321 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
Raimondii is now known as Raimondi
McSoFake has quit [Quit: leaving]
<FromGitter> <eliasjpr> I need some help with this concept https://carc.in/#/r/1x8j
<Papierkorb> eliasjpr, don't use &block AND yield in the same method. Only use one at a time
<FromGitter> <eliasjpr> mmm ok that got me 1 step further
<FromGitter> <bew> Is there a way to bind a block to a specific scope, and call it later ?
<FromGitter> <eliasjpr> It would be nice that when passing blocks and turning them into procs you can set the context for execution. Example take this stores block and execute it later for x context. This way you can pass the block around without concerns of scope execution
<FromGitter> <bew> In fact I know it's not possible currently, but what do you think?
<FromGitter> <eliasjpr> Like an inverted block.call
<FromGitter> <eliasjpr> Something like 'with context exec proc'
<FromGitter> <eliasjpr> Or exec proc within context
<FromGitter> <bew> No a proc has already a context, same as a captured block, which is converted to a proc iirc
<FromGitter> <Sija> @thbar see https://github.com/Sija/any_hash.cr (shameless self-promotion)
greenbigfrog has quit [Ping timeout: 255 seconds]
<FromGitter> <bew> The idea is to transform a non-captured block (so the compiler can still check everything), to a proc on a specific context, something like `proc = yielded_block_with MyContext.new`
greenbigfrog has joined #crystal-lang
<FromGitter> <eliasjpr> :+1:
<FromGitter> <elorest> Is there anyway to centrally cache shards so I don’t to fetch them all the time if I don’t have internet?
bjz has joined #crystal-lang
<FromGitter> <mverzilli> I guess it's not exactly what you're looking for, but you could make them point to a local path https://github.com/crystal-lang/shards/blob/master/SPEC.md#path
<FromGitter> <elorest> I’ll make that work thanks.