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(/(=?,)/)`
<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>
<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…]
<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>
<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?