ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.19.4 | Fund Crystals 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
<travis-ci> crystal-lang/crystal#130ee24 (master - Formatter: fixed wrong block formatting after newline. Fixes #3418): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/167968700
<DeBot> https://github.com/crystal-lang/crystal/issues/3418 (Formatter bug with &block)
bjz has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
pawnbox has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
Philpax_ has joined #crystal-lang
<crystal-gh> [crystal] chocolateboy opened pull request #3425: fix varname typo: original_filanme -> original_filename (master...fix-varname-typo) https://git.io/vP6jk
onethirtyfive has quit [Remote host closed the connection]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 245 seconds]
onethirtyfive has joined #crystal-lang
onethirtyfive has quit [Ping timeout: 260 seconds]
kulelu88 has quit [Quit: Leaving]
HakanD__ has joined #crystal-lang
<FromGitter> <johnjansen> just tripped over this `return nil unless 0 <= offset <= size` in `String#2193` … does it actually work???
Philpax_ is now known as Philpax
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 256 seconds]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 250 seconds]
HakanD__ has quit [Quit: Be back later ...]
HakanD__ has joined #crystal-lang
HakanD__ has quit [Ping timeout: 244 seconds]
Philpax_ has joined #crystal-lang
Philpax has quit [Ping timeout: 265 seconds]
soveran has joined #crystal-lang
Philpax_ has quit [Ping timeout: 260 seconds]
Philpax_ has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
pawnbox has joined #crystal-lang
<BlaXpirit> johnjansen, why not?>
pawnbox has quit [Remote host closed the connection]
Philpax_ has quit [Ping timeout: 260 seconds]
pawnbox has joined #crystal-lang
<Yxhuvud> assuming <= returns its argument if true, it should
<BlaXpirit> no it's a syntax feature
<BlaXpirit> >> 0<1<2
<DeBot> BlaXpirit: # => true - https://carc.in/#/r/1c9w
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
ltran has joined #crystal-lang
<FromGitter> <ddfreyne> Number.divmod is behaving weirdly for me…
<FromGitter> <ddfreyne> >> p 1.234.divmod(0.234)
<FromGitter> <ddfreyne> https://carc.in/#/r/1c9y ⏎ ⏎ output: `{5.2735042735042734, 0.064}` ⏎ I expected `{5, 0.064}` [https://gitter.im/crystal-lang/crystal?at=58034515891a53016314033b]
<FromGitter> <ddfreyne> Hmm, maybe that is expected…
<FromGitter> <ddfreyne> (though incosistent with what Ruby does)
HakanD__ has joined #crystal-lang
HakanD___ has joined #crystal-lang
HakanD__ has quit [Ping timeout: 250 seconds]
<BlaXpirit> ddfreyne, i don't think that's correct
<BlaXpirit> maybe what you expected is correct
<BlaXpirit> it's literally normal division
ltran has quit [Ping timeout: 244 seconds]
HakanD___ has quit [Quit: Be back later ...]
HakanD___ has joined #crystal-lang
A124 has quit [Quit: '']
HakanD____ has joined #crystal-lang
HakanD___ has quit [Read error: Connection reset by peer]
A124 has joined #crystal-lang
<FromGitter> <ddfreyne> Righ… I’ll fix and send a PR
<crystal-gh> [crystal] ddfreyne opened pull request #3426: Fix #divmod for Float (master...denis/bug/float-divmod-int) https://git.io/vPisb
<jokke> can i get the compile time return type of a method of a given type?
<jokke> from a macro
<BlaXpirit> jokke, you can get the type but not in a macro context, so to say
<jokke> :/
<BlaXpirit> you can do typeof(f(5)) but not {% typeof(f(5)) %}
<BlaXpirit> i've recently had to deal with this, maybe i can offer an alternative if u explain
<jokke> BlaXpirit: well i'm desperately trying to write some kind of simple mocking library
<BlaXpirit> ah lol
<BlaXpirit> that's totally mind-boggling
<jokke> so i'm basically wrapping an object with a mock class that basically hooks into method_missing and returns a value that's given to it in form of a mapping
<jokke> i want to check the values in the mapping so that they are of the same type than what the method originally returns
<jokke> it is totally mind-boggling
<jokke> i feel like going way too deep into the rabbit hole
<jokke> but if i can't access the infered type of a macro variable i think i'm doomed
<jokke> also my approach makes it really hard to check for arguments that were passed to the method call
<jokke> because i'd need to know their types in beforehand to store them in a instance variable
<jokke> otherwise i'd need to generate the mocker class on the fly but that's not possible from inside of defs
grindhold_ has quit [Quit: No Ping reply in 180 seconds.]
<jokke> BlaXpirit: so, any alternatives come to mind? :)
grindhold has joined #crystal-lang
ltran has joined #crystal-lang
ltran has quit [Ping timeout: 256 seconds]
soveran has quit [Remote host closed the connection]
Philpax has joined #crystal-lang
<jokke> it's not possible to make procs with splat args?
<jokke> hmm
<jokke> i'm trying to find out the return type of a proc literal
<jokke> but apparently it's not possible
<jokke> undefined macro method 'ProcLiteral#def'
<BlaXpirit> sorry, i'm bailing on this :|
<BlaXpirit> yes there's no way to get return type of anything inside macros
HakanD____ has quit [Quit: Be back later ...]
HakanD____ has joined #crystal-lang
Ven has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 252 seconds]
<crystal-gh> [crystal] timcraft opened pull request #3427: Handle non array return values in Enumerable#flat_map (master...fix-enumerable-flat-map) https://git.io/vPiCW
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 250 seconds]
Ven has quit [Ping timeout: 250 seconds]
Ven has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
Ven has quit [Ping timeout: 244 seconds]
Ven has joined #crystal-lang
HakanD____ has quit [Quit: Be back later ...]
<jokke> BlaXpirit: not entirely correct. You can get the return type of methods
<jokke> so if you actually pass a type to a macro like this my_macro(String, ..) you can use #resolve and then #methods on the first argument
pawnbox has quit [Remote host closed the connection]
<BlaXpirit> jokke, but you need to be aware that this is only the annotated return type which may be missing or not precise enough
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
eizua has joined #crystal-lang
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
ltran has joined #crystal-lang
Philpax has quit [Ping timeout: 245 seconds]
ltran has quit [Ping timeout: 256 seconds]
Ven has quit [Read error: Connection reset by peer]
Ven has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 265 seconds]
<BlaXpirit> so seems like there is no method_missing for class methods :/
<crystal-gh> [crystal] asterite pushed 1 new commit to master: https://git.io/vPi0k
<crystal-gh> crystal/master 9119c33 Ary Borenszweig: Compiler: rename `considered_external` to `c_calling_convention` and don't use it for fun linkage.
pawnbox has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
dhk has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
HakanD____ has joined #crystal-lang
<travis-ci> crystal-lang/crystal#9119c33 (master - Compiler: rename `considered_external` to `c_calling_convention` and don't use it for fun linkage.): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/168057596
HakanD____ has quit [Ping timeout: 256 seconds]
<BlaXpirit> I'm having a problem with nested macro blocks. https://carc.in/#/r/1caj - how do I get the `C` in the 2nd case?
HakanD____ has joined #crystal-lang
<RX14> BlaXpirit, https://carc.in/#/r/1cam
<RX14> easy
<BlaXpirit> wow
<BlaXpirit> good job, thanks
<RX14> the outer macro block will expand
<BlaXpirit> i understand the reason
<RX14> to the same as the first method
<RX14> oh
<BlaXpirit> i would argue that @type should automatically be ignored until the last moment
<BlaXpirit> what do you think?
<BlaXpirit> by 'ignored' i mean something like the escaping that you did
<BlaXpirit> it's difficult and maybe not intuitive but who would ever want the current behavior if it alwaysw returns the type that you're writing code in
<RX14> BlaXpirit, no thats just more confusing
<RX14> and i can think of plenty of reasons
<BlaXpirit> yeah actually it's crazy
<BlaXpirit> it can be part of a bigger expression and it would have to ignore that whole thing
* BlaXpirit closes "New Issue" tab
pawnbox has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
HakanD____ has quit [Quit: Be back later ...]
HakanD____ has joined #crystal-lang
HakanD____ has quit [Ping timeout: 252 seconds]
<BlaXpirit> I'm looking for a very optimal way of converting a bunch of, let's say, 32-bit numbers into a Slice(UInt8)
<BlaXpirit> and the size of the slice may not always be n*3
<BlaXpirit> and the size of the slice may not always be n*4
pawnbox has quit [Remote host closed the connection]
ltran has joined #crystal-lang
pawnbox has joined #crystal-lang
ltran has quit [Ping timeout: 244 seconds]
soveran has joined #crystal-lang
snsei has joined #crystal-lang
soveran has quit [Ping timeout: 252 seconds]
snsei has quit [Ping timeout: 265 seconds]
soveran has joined #crystal-lang
ponga has quit [Quit: Connection closed for inactivity]
snsei has joined #crystal-lang
<BlaXpirit> [1, 2, 3].shuffle(SecureRandom) works
<BlaXpirit> this is the best day of my life
<BlaXpirit> finally i understand what `extend` does
<Yxhuvud> same as include but into the class level.
eizua has quit [Quit: Leaving]
kulelu88 has joined #crystal-lang
ltran has joined #crystal-lang
soveran has quit [Remote host closed the connection]
ltran has quit [Ping timeout: 252 seconds]
<jokke> when does this happen? Bug: trying to upcast String <- String+
HakanD____ has joined #crystal-lang
pawnbox has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
HakanD____ has quit [Ping timeout: 250 seconds]
pawnbox has quit [Remote host closed the connection]
ltran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has joined #crystal-lang
soveran has quit [Changing host]
soveran has quit [Ping timeout: 260 seconds]
<Papierkorb> I'm constantly surprised how few memory crystal programs require, besides how efficient they run
soveran has joined #crystal-lang
HakanD____ has joined #crystal-lang
soveran has quit [Ping timeout: 245 seconds]
soveran has joined #crystal-lang
<RX14> BlaXpirit, did you work out your slice problem?
<RX14> it's for random_bytes right?
<RX14> i was thinking about that too
<RX14> didn't really come up with much
<BlaXpirit> RX14, yeah i have a solution. though didn't code for big endian
<BlaXpirit> basically i create a slice that is too big, not to bother with the end
<RX14> does it really matter?
<BlaXpirit> and cast it to another type and blah
<RX14> BlaXpirit, you could always write some assembly
<RX14> i think you can load numbers into a register then address that register as 4 smaller registers or something on x86
<RX14> BlaXpirit, the slice too large requires an extra memory copy right
<BlaXpirit> RX14, no
<RX14> hmm?
<RX14> of you don't have it like write(sclie)
<BlaXpirit> i think how it works is the memory is allocated and information about it is written into a Slice
<RX14> you return a slice?
<BlaXpirit> but if you make another Slice with different size but the same pointer, it doesnt need another allocation and keeps the original pointer alive
<RX14> I think it might be easier to use byte shifts to extract the bytes
<RX14> handle each unsigned size seperately
<FromGitter> <johnjansen> ok guys here is a philosophical question, should `“hello”.rindex(/.l/)` match `el` or `ll`
<BlaXpirit> certainly not easier
<BlaXpirit> what's philosophical about it
<FromGitter> <johnjansen> haha, yeah
<BlaXpirit> can this even be implemented?
<BlaXpirit> with pcre
<FromGitter> <johnjansen> i got hit by a car, dont pick ;-)
<RX14> well
<RX14> you match against the string
<RX14> and pick the last match
<RX14> or
<RX14> attempt to match strings from the end
<BlaXpirit> yes it is posible, sorry
<jokke> is there a way to get all arguments from within a def without knowing the names or amount of the arguments?
<RX14> they give different results BlaXpirit
<BlaXpirit> johnjansen, it would be 'll' for sure
<FromGitter> <johnjansen> so both ruby and crystal return `el`
<RX14> yep
<RX14> because matches can't overlap BlaXpirit
<FromGitter> <johnjansen> but `ll` seems right to me
<RX14> so matching from left matches el
soveran has quit [Ping timeout: 260 seconds]
<RX14> then doesn't find ll
<RX14> because it overlaps
<jokke> the method is being defined by a macro
<RX14> unfortunately it's hard to implement the other case
<FromGitter> <johnjansen> but this is `rindex`, which is meant to scan from the right, so technically it should be `ll`
<FromGitter> <johnjansen> yeah, thats what i was thinking
<FromGitter> <johnjansen> there is a funny situation here as `rpartition` in ruby does in fact work correctly
<BlaXpirit> RX14, i don't think what you're saying is correct. why is it so certain that matches can't overlap?
<RX14> maybe for each match, start matching from the first match index + 1
<RX14> BlaXpirit, because thats how pcre works
<FromGitter> <johnjansen> but obviously doesnt use rindex
<RX14> thats how regex works
<RX14> they just don't
<BlaXpirit> pcre only implements "search starting at x position"
<BlaXpirit> pcre only implements "match starting at x position"
<RX14> pcre can return multiple matches
<BlaXpirit> it you keep calling it
<FromGitter> <johnjansen> so here is the philosophical part … do we follow ruby or come up with what i think is the correct answer `ll` in this case
<FromGitter> <johnjansen> it makes me wonder how many people have used `rindex`in ruby and not seen this situation arise and pondered
<RX14> hmm
<BlaXpirit> this is definitely not correct behavior, makes no sense at all. in fact, it's best not to have this method
<BlaXpirit> as it seems to be currently
<FromGitter> <johnjansen> haha, so both rindex and rpartition by regex are problematic
bjz has joined #crystal-lang
<BlaXpirit> of course they are
<FromGitter> <johnjansen> haha great
<BlaXpirit> the same regex could match from position 1 to position 7 and also match from position 3 to position 5
<BlaXpirit> which is the last one then?
<FromGitter> <johnjansen> ok i have a PR coming to add rpartition with a Char and String sep, but im going to avoid regex for now
<FromGitter> <johnjansen> YUP !!!
soveran has joined #crystal-lang
<RX14> well
<RX14> regex shouldn't be in the stdlib at all in my opinion
<FromGitter> <johnjansen> it seems like you would need to scan the string backward testing with each additional prefix, then bail on the first matching case
<RX14> like, using regex
<RX14> it should be avoided
<RX14> for perf reasons
<RX14> not remove regex xupport
<FromGitter> <johnjansen> +1
<FromGitter> <johnjansen> thanks guys
<Yxhuvud> honestly, in the ll case I'd submit a bug report to the ruby guys as well.
<RX14> they won't change it
<FromGitter> <johnjansen> too late for them im afraid
<RX14> i'm sure it's been reported
<Papierkorb> Is it possible to dump all fibers and what they're currently doing or waiting for?
<Yxhuvud> how sure?
<RX14> Yxhuvud, ruby has millions of users over 10 years sure
<RX14> and I spotted that bug in 10 mins
<RX14> so
<Yxhuvud> because I wouldn't be certain enough people even know rindex exist, and even takes regexps as an argument (I certainly didn't know the last part of that)
<FromGitter> <johnjansen> id be 50/50 on if this kind of thing has been reported, but ill take a look
<Yxhuvud> they *are* constantly fixing bugs you know, and this totally smells like one.
<RX14> its likely not a bug
<RX14> just how things are
<FromGitter> <johnjansen> haha, back to philosophical again ...
<RX14> its one of those things you can't change until ruby 3
<Yxhuvud> They are perfectly happy changing stuff that they consider pure bugs.
<RX14> well
<RX14> report it if you wish
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
<Yxhuvud> eh, actually, no. at least in ruby 2.3.1 "hello".rindex(/.l/) returns 2. meaning that the match start with the l.
soveran has quit [Remote host closed the connection]
<Yxhuvud> meaning that the method work the obvious way.
<FromGitter> <johnjansen> bloody rvm
<Yxhuvud> so apparently someone *did* notice.
<FromGitter> <johnjansen> yep .. sorry guys
<FromGitter> <johnjansen> the heart of our problem is that `String#scan(Regex)` doesnt find the second match from what i can tell ⏎ ```"hello".scan(/.l/) # => never finds ll``` [https://gitter.im/crystal-lang/crystal?at=5803e83b614116a2568c56e6]
<FromGitter> <johnjansen> note ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5803e8d88eaaaea3669fee2b]
snsei has quit [Remote host closed the connection]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
soveran has joined #crystal-lang
soveran has quit [Ping timeout: 250 seconds]
HakanD____ has quit [Quit: Be back later ...]
HakanD____ has joined #crystal-lang
bjz has joined #crystal-lang
HakanD____ has quit [Ping timeout: 250 seconds]
scottj has joined #crystal-lang
matp_ is now known as matp
<crystal-gh> [crystal] johnjansen opened pull request #3429: String#rpartition (master...string-rpartition) https://git.io/vPi5f
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
daniel has joined #crystal-lang
daniel is now known as Guest15130
Guest15130 has quit [Client Quit]
wlib has joined #crystal-lang
<wlib> hello im having trouble creating temporary files
<wlib> [https://crystal-lang.org/api/0.19.4/Tempfile.html] says i need to run `tempfile = Tempfile.new("file")`
<wlib> but it gives my this error : `undefined constant Tempfile
<wlib> what am i doing wrong
<FromGitter> <raydf> @johnjansen, that's default behavior for regex.
<FromGitter> <raydf> try with http://regexr.com/ and you'll see the same.
<FromGitter> <jwoertink> Wouldn't you want `/.l+/` to match more than one?
<FromGitter> <johnjansen> String#scan *Searches the string for instances of pattern, yielding a Regex::MatchData for each match.**EACH* being the operative word … so why not yield all of [‘el’, ‘ll’] since the both match
<FromGitter> <raydf> because overlapping
<FromGitter> <johnjansen> understood … @raydf
<FromGitter> <johnjansen> unfortunately this is causing a deviation from ruby in String#rindex
<FromGitter> <johnjansen> although scan itself is correct …arrrggh
<FromGitter> <raydf> I haven't used much ruby, sorry, didn't knew about difference in behavior.
<BlaXpirit> wlib, you probably need to import the module that contains that
<BlaXpirit> Defined in: tempfile.cr -> `require "tempfile"`
soveran has joined #crystal-lang
<wlib> silly me, thanks @BlaXspirit
wlib has quit [Quit: Page closed]
soveran has quit [Ping timeout: 245 seconds]
snsei has joined #crystal-lang
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
ltran has quit [Quit: leaving]
ltran has joined #crystal-lang
ltran has quit [Client Quit]
<FromGitter> <raydf> @johnjansen, you can do this: ⏎ ```pp "hello".rindex(/.*\K.l/)``` [https://gitter.im/crystal-lang/crystal?at=58040c688eaaaea366a05e45]
<FromGitter> <johnjansen> yeah, sorry @raydf this relates to a specific deviation between the way rpartition and rindex work (in ruby) so im not so much looking for regex help as well help from the man above
<FromGitter> <raydf> \K removes the part found by the first ".*". Of course still that's a very different behavior from ruby
<FromGitter> <raydf> :)
<FromGitter> <raydf> i wrote at the same time :)
<FromGitter> <johnjansen> one would think that you could use rindex to implement rpartition for regex seperators
<FromGitter> <johnjansen> but alas, rpartition should split “hello” into [“he”, “ll”, “o”] with /.l/ but rindex find ‘el’ not ‘ll'
<FromGitter> <johnjansen> +s
HakanD____ has joined #crystal-lang
<FromGitter> <raydf> maybe a pure crystal re can be implemented? https://rxr.whitequark.org/mri/source/re.c, of course that would be a big shard :)
HakanD____ has quit [Ping timeout: 256 seconds]
<FromGitter> <raydf> or maybe use this c lib?
snsei_ has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]