jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.18.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
bcardiff has quit [Quit: bcardiff]
bcardiff has joined #crystal-lang
pawnbox has joined #crystal-lang
bcardiff has quit [Client Quit]
<travis-ci> crystal-lang/crystal#a8dc441 (master - Merge branch 'release/0.18'): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/140151820
pawnbox has quit [Ping timeout: 244 seconds]
<travis-ci> crystal-lang/crystal#409cd76 (release/0.18 - Fixed HTTP::Request specs): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/140151825
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
rvchangue has quit [Quit: dead]
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
snsei has joined #crystal-lang
Philpax has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 260 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
ome has joined #crystal-lang
Raimondii is now known as Raimondi
ponga has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
matp has quit [Remote host closed the connection]
matp has joined #crystal-lang
ome has quit [Quit: Connection closed for inactivity]
<crystal-gh> [crystal] marceloboeira opened pull request #2911: Add temporary directory file creation on Dir class (master...feature/mktmpdir) https://git.io/vo9kZ
pawnbox has joined #crystal-lang
snsei has quit [Remote host closed the connection]
pawnbox has quit [Ping timeout: 244 seconds]
snsei has joined #crystal-lang
pawnbox has joined #crystal-lang
pawnbox has quit [Ping timeout: 258 seconds]
bcardiff has joined #crystal-lang
bcardiff has quit [Client Quit]
snsei has quit [Remote host closed the connection]
pawnbox has joined #crystal-lang
sandelius has joined #crystal-lang
pawnbox has quit [Ping timeout: 272 seconds]
pawnbox has joined #crystal-lang
Redfoxmoon has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 264 seconds]
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
<sandelius> if I compile my code on osx will I be able ru run it on linux or do I need to compile it there aswell?
<RX14> you need to recompile
<RX14> i think it's technically possible to cross-compile though, if a little complex
A124 has quit [Read error: No route to host]
<jhass> you can cross compile but you need to link on the target host or a compatible chroot
<RX14> yup
<RX14> rust has a really nice tool for automating this
<RX14> i imagine crystal could get one too but it's not really worth it yet
<RX14> it's not particularly high on the agenda at least
A124 has joined #crystal-lang
<RX14> uhh
<RX14> my crystal is broken
<jhass> how did the exam go btw?
<RX14> jhass, easiest exam i've ever done :)
<jhass> haha, cool
<jhass> RX14: let's sanitize first, git pull; make clean; make;
<RX14> i have
<RX14> oh
<RX14> two makes?
<RX14> no
<RX14> i doubt it'll work
<jhass> make clean so you compile the compiler with the latest release
<RX14> yeah
<RX14> it fails to compile itself second time
<jhass> that working is the only thing we really guarantee
<RX14> i have
<RX14> i did a git pull
<RX14> make clean crystal spec
<RX14> it built itself
<RX14> and the specs failed to compile
<RX14> same error
<RX14> just running make fails to compile itsel
<RX14> f
<BlaXpirit> RX14, let's calm down, please write exactly what you did, or do exactly what jhass writes
<RX14> i jid just write exactly what i did
<jhass> yes, MAKEFLAGS="-jfoo" may mess up your way
<RX14> and it is almost exactly what jhass wrote
<BlaXpirit> "make clean crystal spec" is probably not valid
<jhass> make -j1 clean crystal std_spec
<RX14> i dont have makeflags
<RX14> its not in parallel
<jhass> well it works okay for me
<jhass> git add .; git stash
<jhass> then redo the ordeal
<RX14> hmmn it breaks on my branch but not master
<RX14> but i havent done anything to the compiler
<jhass> well you added something to IO's ancestry chain
<RX14> so apparently changing IO::Sized to a class not a struct fixes it, but I thought this was meant to genberate a compiler error now
<jhass> mh yes it was
<RX14> aparently not
<RX14> considering said error
<jhass> guess you got a case that's still undetected then
<RX14> jhass, is there an easy way to convert from array to lice?
<RX14> slice*
<jhass> to_slice ?
<RX14> doesnt exist
<jhass> mh
<jhass> well, Slice.new(ary.to_unsafe, ary.size) then I guess
<RX14> mmm
<RX14> ended up calling String.new(slice) and then comparing in the specs
<RX14> i hate the default spec assertions
<BlaXpirit> RX14, should we start a movement?
<RX14> BlaXpirit, bring power_assert to the stdlib?
<BlaXpirit> something lke that
<RX14> i mean
<RX14> it's way more readable
<BlaXpirit> every sane language is moving towards that
<RX14> the errors are more debuggable
<RX14> it's easier to write
<RX14> it's just a cleaner nicer solution for a langauge with macros
<BlaXpirit> python initially had a collection of dumb assertion functions stupidly copied from java
<RX14> i guess if i'm getting support I should open a github issue
<BlaXpirit> oh and you have to define meaningless "test classes" to do anything
<BlaXpirit> now everyone is thankfully moving away from that, to a lib where you just write def test_something(): assert 1==2
<BlaXpirit> crystal similarly has everything copied from ruby without knowing any better
<RX14> groovy has power assertions in the langauge
<RX14> and it's amazing
<RX14> to be honest
<RX14> spock is literally the best test framework I have ever used
<RX14> especially this
<RX14> it's fantastic
<BlaXpirit> should be possible to make a utility to drop the ridiculous assertion DSL
<BlaXpirit> RX14, now now, one step at a time
<RX14> yeah yeah i nkow
<RX14> but still
<RX14> we don't need to make a utility
<RX14> power_assert.cr exists
<BlaXpirit> RX14, no i mean convert existing spec code
<RX14> ohh
<RX14> hmmn
<RX14> yeah i guess
<RX14> i'll try and convert a test file from the stdlib to the new assertions and see how people like it and then we can see where itgoes
<RX14> or you can, if you want, i'm working on multipart parsing
trapped has joined #crystal-lang
<BlaXpirit> RX14, you mean manually? yeah i can try
<BlaXpirit> better find a convincing one
<RX14> yeah
<RX14> i meant the whole github issue
<RX14> you can convert a file if you want
<RX14> it could just be one test case
<BlaXpirit> sure
<RX14> or a few good examples
<BlaXpirit> I'm on it, and I will tell you if I change my mind
<RX14> and maybe show the error output in said cases
<RX14> BlaXpirit, my fork of power_assert is updated to latest crystal https://github.com/RX14/power_assert.cr
<BlaXpirit> yup
trapped has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
<BlaXpirit> 95% of this is .should eq
<RX14> i would say that more complex assertions are easier without the dsl too
<RX14> you can call .any? and such
<RX14> and it works great
<BlaXpirit> then there is CloseExpectation which is probably actually useful
<BlaXpirit> > (actual_value - @expected_value).abs <= @delta
<RX14> hmmn
<BlaXpirit> and expect_raises
<RX14> thing is you just need to implement that as a method
<RX14> assert_raises could be a thing
<RX14> just rename it
<BlaXpirit> yeah that one is fine but "close"
<RX14> but for 99% of cases it's cleaner
<RX14> just make a custom helper for the small amount of test cases
<RX14> or add it to the stdlib on floats
<RX14> .close? should be useful outside specs
<BlaXpirit> yeah floats could be nice, indeed
<RX14> it's always floats
<RX14> yeah
<RX14> that looks good
<BlaXpirit> you mean bad :p
<RX14> depending of your point of view, yes
<BlaXpirit> welp, I got a HUUUGE traceback with your power_assert
snsei has joined #crystal-lang
<RX14> my one?
<RX14> can you paste it
<BlaXpirit> RX14, https://carc.in/#/r/12h1
<RX14> execution timed out isn't exactly helpful
A124 has quit [Ping timeout: 260 seconds]
<RX14> can you paste the error was what I meant
<BlaXpirit> RX14, yeah if I copy it to a local file and run I get a huge output
<jhass> well looks like it's a lot slower than spec
<RX14> jhass, no, in the succesful case it's just running the expression
<jhass> still a shitload more work for the compiler on every call
<RX14> maybe so
<RX14> but it's nicer
snsei has quit [Ping timeout: 258 seconds]
<RX14> benchmark it first
A124 has joined #crystal-lang
<RX14> looks like a recursive get_ast happened
<BlaXpirit> RX14, assert($~[0] == "oo") causes that
<RX14> hmmn
<RX14> it recursively calls get_ast on the reciever and args
<RX14> call assert($~[0])
<RX14> i wonder if just assert($~) breaks
<BlaXpirit> RX14, yes, breaks
<RX14> which one?
<BlaXpirit> both
<RX14> hmmn
<RX14> interesting
<RX14> which mens $~ is a Call in the ast
<BlaXpirit> traceback looks the same in all cases
<RX14> which is weird
<RX14> because $~ is not a call to me
<BlaXpirit> RX14, well it's a very special thing, it's not actually a global. something like a threadlocal probably i dunno
<BlaXpirit> or just a local even
<RX14> well it seems to have a recursive AST
<RX14> whatever it is
<jhass> I think I would call it stack or fiber local
soveran has joined #crystal-lang
<RX14> but what is it in the AST?
<jhass> it's essentially a secondary return value or implicit block parameter, depending on context
<jhass> no idea
<RX14> thats
<RX14> oh
<RX14> well
<RX14> jhass, do you know a testable closable IO?
<jhass> MemoryIO?
<RX14> it's closable?
<jhass> I think so
<RX14> oh dear
<RX14> it was just me
<RX14> referencing the wrong varaible
<RX14> ok specs pass for IO::Sized
<jhass> <3
soveran has quit [Remote host closed the connection]
<RX14> i should have written docs
<RX14> oh well i'll go back and do that later
<sandelius> is crystal used in production that you guys know of?
<RX14> yes but we don't reccomend it
<sandelius> what's the catch with crystal? with parallelism this would be the most ultimate tool I ever seen.
<sandelius> and I read that that will come before stable realse
<RX14> well
<RX14> it doesn't run on windows yet
<RX14> but that shoukd be fixed soon too
<RX14> and parelelism is being worked on right now I think
<sandelius> even the stdlib is great atm
<BlaXpirit> i wouldn't hope for windows soon
<RX14> BlaXpirit, i would
<BlaXpirit> what evidence?
<BlaXpirit> nobody's doing it
<sandelius> windows in not a big issue for me tho, I'm gonna build and run on unix systems
<RX14> BlaXpirit, ary half-implied he would look at it after doing parellelism
<sandelius> how are you guys planning to implement parellelism?
<jhass> sandelius: the biggest catch probably is that each non patch release (and sometimes even those) break half the ecosystem and needs to be updated
<RX14> sandelius, thread pool
<jhass> that runs fibers
<RX14> yep
<RX14> what about IO though i'm still cofnfused
<sandelius> jhass well the the status say: "The project is in alpha stage: we are still tweaking the language and standard library." so that is something one would expect at this stage
<jhass> sure, it might just make it hard to argue for a production app
<sandelius> jhass yeah that's true
<jhass> the other catch is that some things are simply not possible yet since the generic type system needs some more work still
<sandelius> jhass like using a type Class :)
<jhass> you can find workarounds for most of it, but it's not as elegant as it could be
<sandelius> jhass Hash(Symbol, Class)
<jhass> yes
<BlaXpirit> well it's not possible in other languages and nobody's complaining
<RX14> BlaXpirit, using an array of generic pointers is possible in most langauges
<RX14> as in
<jhass> the Class is just the special case of a more general issue
<RX14> array of object
<RX14> no
<RX14> reference
<jhass> RX14: you mean parallel reads?
<jhass> or writes?
<RX14> jhass, i thought evented IO/distributing the IO load evenly was an issue
<jhass> mh, not sure I follow
<sandelius> how would I initialize a hash that looks like this? https://gist.github.com/sandelius/5c70326ff46ef1c7bfd4a71473ac4e89
<BlaXpirit> sandelius, the approach seems dubious. why must this be a Hash?
<RX14> sandelius, plus that's the named tuple syntax now, not hash
<RX14> another breaking change
<jhass> +1 to both ^, but to the answer the question, use alias
<sandelius> RX14 ohh that's why I got that error. now it makes more sense :) I got no match for named tuple
<RX14> sandelius, i would reccomend reevaluating your use of a hash though
<sandelius> RX14 well the schema is a class that contains a hash called attributes
<RX14> this looks like ruby but it's best practices are very different
<sandelius> RX14 well I'm coming from ruby so :)
<RX14> sandelius, that's a description of what it is but why do you need to use a hash?
<jhass> to map schemas crystal developed the mapping idiom
<RX14> why can't it be a custom dsl or something
<sandelius> RX14 I build it like that when I'm merging several schemas
<sandelius> so "hashes" with the : syntax is named tuples and => are hashes?
<RX14> why can't it be a tree of classes/structs
<jhass> sandelius: yes
<RX14> if you know the keys
<sandelius> RX14 it can, I'm just exploring
soveran has joined #crystal-lang
<RX14> jhass, is getting 0 back from IO#read always the end of the stream?
<BlaXpirit> RX14, assuming it's a blocking function, yes
<RX14> it could be ANY io
<BlaXpirit> RX14, lol it's so funny, whenever you use $~ it seems to be expanded to $~.not_nil! in the AST? no idea
<RX14> uhh
<RX14> the hell
<jhass> RX14: I think so, yes
<jhass> given all our IO should block from the caller perspective
<RX14> jhass, same if it doesn't return slice.size bytes?
<jhass> mh, I'm not sure but I hope so
<BlaXpirit> if I write `assert $~` , the expression ends up as '$~.not_nil!.not_nil!', if I write `assert $~[0] == "oo"`, the expression ends up as '$~.not_nil!.not_nil!.not_nil!.not_nil!'
<RX14> this
<RX14> is very very very very weird
soveran has quit [Read error: Connection reset by peer]
<BlaXpirit> and obviously if you try to remove one level from it and receive the caller or whatever, the result is the same exact expression because it also adds another layer of .not_nil!
<BlaXpirit> it's a bug of crystal probably
soveran has joined #crystal-lang
<BlaXpirit> gotta try to separate if from power_assert
ponga has quit []
<BlaXpirit> it*
<RX14> BlaXpirit, make an issue for it
<RX14> say it's basically impossible for macros to deal with it
<RX14> and now there's a helicopter hovering right over my house
<RX14> great
<jhass> haha, guy got arrested in berlin the other day for bringing one down with a laser pointer
<RX14> what an idiot
<jhass> it's too comical
<RX14> like, he brought one down completely?
<RX14> crashed it?
<jhass> it was a police one at night while they were evicting an occupied house
<jhass> guy was 60+ and annoyed by the noise
<jhass> so he managed to burn the pilots eye and the copilot had to land
<RX14> oh
<jhass> the situation is so bizarre
<RX14> well thats not as bad as i was expecting
<jhass> I mean it wasn't even the antifa being evicted there, but some guy who probably was happy to seem them removed from his neighbourhood otherwise
<jhass> *that was being
<RX14> yeah
<RX14> why is there no slice#copy_top)Slice)
<RX14> why is there no slice#copy_to(Slice) *
<RX14> just copies x bytes to another slice, filling it up, and returning amount copied
<jhass> mh, isn't there an issue for that somewhere?
<jhass> why you need it though?
<RX14> copy from the delimiter buffer to the reading slice in IO::Delimited
<jhass> huh
<jhass> reading slice == the one you get?
<RX14> yes
<jhass> I thought we'd stop before the delimiter?
<RX14> when i encounter the first byte of the delimiter, I read the rest into a small buffer
<jhass> ah
<RX14> then i'm trying to handle the case where the stream ends before the buffer fills up
<sandelius> what's the technical differens between a hash and a named tuple?
<RX14> and then the buffer doesn't fill up AND the remaining needs to be copied to the reader slice
<jhass> wouldn't it be easier to just keep an index into the delimiter and a flag?
<jhass> ah wait, nvm
<RX14> it's harder that way
<RX14> well of course
<RX14> you don't want the delimiter bytes in the output
<jhass> eh, I guess just add it ;P
<jhass> should be as simple as a few boundary checks and a memcpy
<jhass> RX14: or actually you should be able to just reuse https://github.com/crystal-lang/crystal/blob/master/src/slice.cr#L238-L240
<jhass> mh, no that thing is weird
<RX14> jhass, exactly
<jhass> why would it start at count and then go for count
<RX14> i have to do the countring and bounds logic myself
<RX14> jhass, no
<RX14> it doesn't
<RX14> look at def pointer(size)
<jhass> ah so the size is just a sanity check there
<jhass> weird
<RX14> yup
<jhass> so def copy_to(slice : self); pointer(slice.size).copy_to(slice.pointer, slice.size); end
<jhass> or just def copy_to(slice : self); copy_to(slice.pointer, slice.size); end; actually
<RX14> no
<RX14> thats not the correct semantics i think
<jhass> well you want copy_from I guess
<RX14> uhh
<jhass> slice.copy_from(delimiter)
<RX14> ahh
<RX14> yes
<jhass> mh and that with an offset arg
<RX14> nah
<RX14> offsets are easy
<RX14> copy_fron(slice + offset)
<RX14> or
<jhass> but it'll copy to the start of the slice
<RX14> (slice + offset).copy_from(slice)
<jhass> ah yeah, more like that
<RX14> yeah
<RX14> thats what i meant
<RX14> but it's still not the right semantics because if the slice you're copying from is larger it'll throw
<jhass> well it should?
<RX14> i would prefer a version which just copies what it can and returns the size
<jhass> mh
<jhass> (slice + offset).copy_from(delimiter[0, slice.size - in_slice_read_bytes])
<jhass> (slice + offset).copy_from(delimiter[0, slice.size - offset])
<RX14> and if "slice.size - offset" is larger than the selimiter?
<RX14> you need a math.max in there somewhere
<RX14> well
<RX14> {}.max
<RX14> exactly
<RX14> i don't want it to throw
<jhass> but given all the slice stuff raises on bounds related things
<RX14> thats a legal condition in my code
<jhass> it probably should remain a callside responsibility for now
<RX14> no it raises when you try and ask it to do something stupid explicitly
<RX14> that doesn't set a precedent for copying to raise if the user hasn't truncated the slices right
<RX14> BlaXpirit, sorry for not replying, thanks
snsei has joined #crystal-lang
<RX14> BlaXpirit, you should just submit the copied test case with the $~ case commented out with a note to #2912
<jhass> RX14: anyway, Slice#copy_from(Slice) should probably have its own commit too then ;)
<RX14> *sigh*
<BlaXpirit> RX14, I don't understand
<RX14> BlaXpirit, the issue for moving to assert
<RX14> comment out the $~ line
<RX14> with anote to this issue
<BlaXpirit> ah of course, that'll be in another issue
<RX14> and submit it
<RX14> was what i was saying
<BlaXpirit> RX14, well I thought you'd write it. i got the example ready
<BlaXpirit> but honestly it might be worth improving power_assert before doing this. there are some cases where it's less clear
<BlaXpirit> improving power_assert will not go to waste anyway, no risk here
<RX14> yeah
<RX14> what improvements do you have in mind?
snsei has quit [Ping timeout: 244 seconds]
<BlaXpirit> RX14, here are some things https://gist.github.com/72ef9c211749b00faa72784091998d64 - the 3rd one is probably not something that needs improvement, just put it there
<BlaXpirit> 1) types are probably important 2) is_a? and other such things should probably be specialcased
soveran has quit [Remote host closed the connection]
<RX14> and we should resugar some things?
<RX14> especially array accessors
<RX14> BlaXpirit, what's the compile times for the testcases before and after?
<BlaXpirit> no idea. well this is a small thing, difference probably negligible?
<BlaXpirit> and indeed it seems to be negligible
<crystal-gh> [crystal] MakeNowJust opened pull request #2913: Introduce Order as a return of `<=>` instead of Int32 (master...feature/order) https://git.io/vo9cK
<RX14> BlaXpirit, yeah real test is the whole stdlib tests though
<BlaXpirit> well that's already a small risk if we decide to go through with it and get rejected
<RX14> yeah
<BlaXpirit> regex probably can't do it, need something like the formatter. or manual work, ugh :s
<RX14> nah we can do it i'm sure
<RX14> as in the formatter
<RX14> also regex could get 90% i bet
<RX14> s/^(.*?).should eq(.*?)$/assert \1 == \2/
<RX14> i wish we could define user-defined annotations as macros
<BlaXpirit> would probably want a good tool, to apply to any code, not just stdlib with manual verification
<RX14> BlaXpirit, yep
<BlaXpirit> RX14, maybe comments could serve that role, if they were included in ast
<RX14> but how would you trigger a macro then?
<BlaXpirit> oh you're looking at something else like @[ ]
<RX14> yes
<BlaXpirit> it could be pretty convincing to allow to use macros there
<BlaXpirit> especially because all existing things are @[Uppercase]
<BlaXpirit> @[lowercase] could be equivalent to lowercase( ... )
<BlaXpirit> i dunno
<RX14> mmm
<BlaXpirit> but it's difficult to write macros that utilize this!
<RX14> yep
trapped has quit [Read error: Connection reset by peer]
buggs2 has joined #crystal-lang
dhk has joined #crystal-lang
joshcarter_ has joined #crystal-lang
emmanueloga_ has joined #crystal-lang
pabs_ has joined #crystal-lang
<BlaXpirit> welp, the formatter is huge, didn't expect that
<BlaXpirit> I kinda did expect but hoped it reused more code
maxpowa_ has joined #crystal-lang
jokke1 has joined #crystal-lang
emmanueloga has quit [Ping timeout: 258 seconds]
buggs1 has quit [Ping timeout: 258 seconds]
aemadrid has quit [Ping timeout: 258 seconds]
tubbo has quit [Ping timeout: 258 seconds]
matp has quit [Ping timeout: 258 seconds]
steenuil has quit [Ping timeout: 258 seconds]
pabs has quit [Ping timeout: 258 seconds]
jokke has quit [Ping timeout: 258 seconds]
avdi has quit [Ping timeout: 258 seconds]
Arahael has quit [Ping timeout: 258 seconds]
joshcarter has quit [Ping timeout: 258 seconds]
maxpowa has quit [Ping timeout: 258 seconds]
aemadrid has joined #crystal-lang
maxpowa_ is now known as maxpowa
joshcarter_ is now known as joshcarter
aemadrid has joined #crystal-lang
aemadrid has quit [Changing host]
tubbo has joined #crystal-lang
matp has joined #crystal-lang
emmanueloga_ is now known as emmanueloga
avdi has joined #crystal-lang
Arahael has joined #crystal-lang
bjz has joined #crystal-lang
bjz_ has quit [Ping timeout: 264 seconds]
<RX14> jhass, I have copy_from(src) just call src.copy_to(self), should I duplicate the specs?
<jhass> I'm afraid yes
<RX14> nah i don't mind a bit of copying
<RX14> in specs especially copying isn't the worst thing ever
<RX14> vim certainly makes it easy ;)
<jhass> yeah, agreed
<jhass> and who knows, it's better it's there in case somebody wants to change/extend the semantics for one but the other
<RX14> :'<,'>s/src.copy_to(dst)/dst.copy_from(src)/ :)
<jhass> or optimize somehow or whatever
<RX14> yup
dhk has quit [Quit: Leaving]
snsei has joined #crystal-lang
<crystal-gh> [crystal] 0joshuaolson1 opened pull request #2914: Fix ||= and &&= definitions (gh-pages...patch-1) https://git.io/vo9B4
willl has joined #crystal-lang
<RX14> syntax highlighted
<jhass> mmh, I think read_delimiter should be Bytes too
<RX14> it is
<RX14> lol
<jhass> oh overload -.-
<RX14> yep
<jhass> I think I need to eat something and then get back to you
<RX14> heh
<RX14> ok
<jhass> wait how does this work
<jhass> String#bytes returns Array(UInt8) not Slice(UInt8)
<jhass> that should be String#to_slice there, no?
<RX14> i havent actually compiled it, silly
<RX14> heh
<RX14> i should probably do that
rolha has joined #crystal-lang
<jhass> why read_utf8_byte?
<RX14> i think streams can have different encoding
<RX14> IOs*
<RX14> it's what they go in gets(String) anyway
<RX14> do*
<RX14> which is half of the same task
<RX14> except it's easier
<jhass> none of this should need to be valid UTF8
<jhass> or care about encoding
<jhass> if you're given a UTF-8 encoded delimiter and the stream isn't UTF-8, their problem
<RX14> well
<RX14> thats what gets(String) does
<jhass> since it handles strings
<jhass> this shouldn't
<RX14> hmmn
<RX14> yep
<RX14> i agree
<RX14> thanks
pawnbox_ has joined #crystal-lang
pawnbox has quit [Ping timeout: 250 seconds]
<RX14> i wish crystal had a branch coverage tool
<jhass> RX14: I think one more flag and keeping a single @delimiter_buffer will be cheaper
<RX14> hmmn
<RX14> it's easier this way though
<RX14> you thinking of storing the size
<RX14> and using just that
<RX14> because we know the maz size
<RX14> max*
<RX14> let me get it working this way first
<RX14> then we have some specs
<RX14> lol i was getting this funny error then i realised my debug code in IO::Delimited was using the puts of that class
<crystal-gh> [crystal] bcardiff closed pull request #2914: Fix ||= and &&= definitions (gh-pages...patch-1) https://git.io/vo9B4
<jhass> RX14: yeah happened to me two at least two times working on IO :D
<RX14> jhass, whats wrong with the condition on the while loop?
<jhass> there is something wrong with it? :D
<RX14> yup
<RX14> i just figured it out
<RX14> well specs pass now
<jhass> cool
<jhass> refresh gist?
<RX14> but that would tell yout the answer to whats wrong with the while loop :)
<jhass> heh
<jhass> well there's still read_utf8_byte in mine :P
<RX14> jhass, well there you go anyway
<jhass> ah I see, makes sense
<jhass> I guess that's why I tend to dislike assignments in conditionals and especially loops
<RX14> it has to be that way round or it discards the byte
<RX14> and yeah i suppppse
<RX14> suppose*
<RX14> but i winder if this is faster
<jhass> but then I see why people dislike break's, so...
<RX14> i don't mind break/next
<RX14> at all
<RX14> i just think this is cleaner
<jhass> sure
<jhass> shall we try to get rid of the repeated allocation on line 43?
<RX14> yeah i suppose I can do that
<jhass> I would really just add a second flag and use it in line 30
<RX14> jhass, thing is
<RX14> you're going to need 2 flags if you want it to be 0 allocation
<jhass> other variant would be to keep it like that but have a @buffer_cache where you keep one
<RX14> a start and an end
<RX14> because of line 56
rolha has quit [Ping timeout: 244 seconds]
<jhass> so what about my second idea?
<RX14> ?
<RX14> how does that work
<jhass> @delimiter_buffer = Bytes.new(@read_delimiter.size); @active_delimiter_buffer = nil;
<jhass> replace all your @delimiter_buffer with @active_...
<RX14> ohhhh
<RX14> thats
<jhass> and do buffer = @delimiter_buffer
<RX14> not a bad idea
<RX14> thats fantastic
Philpax has quit [Ping timeout: 246 seconds]
<jhass> I'd rename buffer_copied to copied_bytes
<jhass> seems to be more inline with read_bytes
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 250 seconds]
<RX14> jhass, buffer_read_bytes and buffer_copied_bytes?
<jhass> fine with me if that's not too long for your taste
Raimondii is now known as Raimondi
<RX14> jhass, well we have read_bytes, buffer_read_bytes and buffer_copied_bytes
<RX14> i think thats the only logical names
<jhass> yeah I guess so
<RX14> i have a bug
<RX14> and i'm stick
<RX14> stuck*
triangles has quit [Quit: Leaving]
<RX14> oh i read the output wrong
<RX14> this is bad
<RX14> looks like i forgot something major
<RX14> jhass, we'll have to search the buffer too
<jhass> ah, right
<jhass> well, back to my copy byte by byte into the buffer while keeping an index into the delimiter
<jhass> idea
<RX14> that doesn't work
<jhass> mh, right it doesn't
<RX14> because it doesn't handle the case where the delimiter crosses the boundary at all
<jhass> shift out the buffer into the slice while buffer[0] == first_byte ?
<jhass> until it's empty again
<RX14> well we just have to have logic at the top of the loop to decide whether to read the buffer or IO
<jhass> mh
<jhass> yeah I guess
<jhass> then shift the remaining stuff in the buffer to the front and refill it from the io
<RX14> no
<RX14> shift until empty
<RX14> then fallback to IO
<jhass> I don't think that works
<RX14> why?
<jhass> say first_byte == a and you got [0, 0, a, b, c] as @active_delimiter_buffer/@delimiter_buffer
<jhass> you shift up to a
<jhass> then overwrite b, c with @io.read
rolha has joined #crystal-lang
<RX14> yeah i know that bug
<jhass> that's what I meant with shift to front earlier
<jhass> and then fill the rest with @io.read
<RX14> hmmn
<jhass> it sucks that it's another copy but I see no sane way around it
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<RX14> should have just returned the multipart as a Bytes
<jhass> @delimiter_buffer.copy_from(@active_delimiter_buffer)
<RX14> i'm like 5 levels deep of "oh i'll just do that before I do this" right now
<jhass> I know, sorry
<RX14> oh i'm doing this, oh i need a multipart lib, oh i need a bounded stream implementation
<RX14> heh
<RX14> someone had to do it
<jhass> <3
<RX14> jhass, does that even work?!?
<jhass> should no?
<RX14> because active is a pointer in the buffer
<RX14> yeah i guess it does
<jhass> then even just @io.read(@active_delimiter_buffer); @active_delimiter_buffer = @delimiter_buffer to refill
<RX14> i'm also a little lost right now
<jhass> I think
<jhass> yes I think first thing you should try to write a spec for the case I mentioned
<RX14> yeah
<RX14> oh boy
<RX14> index out of bounds
<RX14> even
<RX14> where's my line number info :/
pochito has joined #crystal-lang
rolha has quit [Remote host closed the connection]
rolha has joined #crystal-lang
pabs_ is now known as pbas
pbas is now known as pabs
<jhass> my last line is wrong btw
<jhass> @io.read(@delimiter_buffer + @active_delimiter_buffer.size); @active_delimiter_buffer = @delimiter_buffer to refill
<RX14> but then what if we fill up delimiter_buffer?
<RX14> is that possible?
<RX14> well
<RX14> yeah
<RX14> we will need to maintain and resize our own variable-length buffer.
<RX14> actually
<RX14> hmmn
<RX14> what on earth
<RX14> no
<RX14> you're right
<RX14> hel;p
<jhass> :o
<RX14> expected: "ab12312"
<RX14> got: "ab11312222"
<RX14> jhass, this is too complex
tilpner has quit [Quit: :wq]
tilpner has joined #crystal-lang
<jhass> could write a ringbuffer and copy each byte twice.... :P
Raimondii has joined #crystal-lang
<RX14> yeah
<RX14> hmmn
Raimondi has quit [Ping timeout: 240 seconds]
<RX14> jhass, we just need to fix restocking the buffer when we need to search
<jhass> yeah?
<RX14> hmmn
<RX14> i think
<jhass> can you update the gist?
<RX14> wait
<RX14> jhass, how do you run only one spec again?
<RX14> ah
<RX14> got it
<jhass> crystal spec spec/foo_spec:12
Raimondii is now known as Raimondi
<RX14> yay infinite loop
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<BlaXpirit> btw i wrote a ring buffer though for a different usage - that's the Deque
<RX14> nah i've got this sorted
<RX14> kinda
<RX14> fuck
<RX14> no i don't
<RX14> yes i do
<RX14> kek
<RX14> my mind is just frazzled, after i get this fixed i'm just going to relax
rolha has joined #crystal-lang
<RX14> shit
<RX14> just when i thought it would have worked
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
<RX14> i have it
<RX14> in my head
<RX14> i know how this is going to work
<RX14> now i just need to make it beautiful
<FromGitter> <sdogruyol> It's a multipart parser right?
rolha has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<RX14> a generic bounded stream
<RX14> an IO that stops reading BEFORE encountering a byte sequence
<RX14> which is hard
<jhass> RX14: could you gist your specs?
<jhass> wanna try something
<RX14> jhass, https://aww.moe/w03byc.txt what have I done
<jhass> haha
<RX14> jhass, it's fine until the underlying stream runs out
<RX14> and then we need to signal how much bytes are left valid in the buffer
<RX14> and i can't get it working
<RX14> OR beautiful
<RX14> or anything except that
<RX14> and i'm stuck
<RX14> jhass, that's off-by-one
<RX14> it was off-by-two earlier
<RX14> jhass, here are my specs: https://aww.moe/qkj7dr.txt
<RX14> having a clipboard to URL keyboard shortcut is great
<RX14> now I just need to make it syntax highlight
<jhass> just use my pastebin instead :P
<RX14> nah
<jhass> thanks
<RX14> at least I own aww.moe...
<RX14> anyway i'm going to do something else for now
<RX14> if you get inspiration on how to signal how much valid bytes are left in the buffer in a clean way go ahead and fix it
<RX14> maybe it would just be easier to use a deque and a custom kind of comparison function for a deque
triangles has joined #crystal-lang
<jhass> that's basically what I'm trying currently actually
<jhass> copying twice sucks but it's maybe not worth the headache
<RX14> i think this method is better if we get it right
<jhass> yes
<RX14> and i can't believe its that hard
<RX14> we're just off by one and quagmired in bad code
qard has joined #crystal-lang
rolha has joined #crystal-lang
<RX14> jhass,
<RX14> i fixed it
<jhass> <3
<RX14> by adding a +1
<jhass> haha
<RX14> i just had to go and do something else
<RX14> and
<RX14> come back
<RX14> clear my mind
<jhass> yeah, I know that feeling
<RX14> now all i needs is a `# Abandon all hope, ye who enter here` and we can ship it
<jhass> 3 hardest things in computer science, naming things and off by one errors
<RX14> heh
<FromGitter> <sdogruyol> Add caching also
<FromGitter> <sdogruyol> :smile:
<RX14> caching is easy
<RX14> cache invalidation is hard
<FromGitter> <sdogruyol> Yeah
<RX14> that why i try and make things fast enough not to be cached
<RX14> heh
<RX14> jhass, there MUST be a cleaner way to do this: https://gist.github.com/RX14/ce476085f11f19473cbb311cdd12ad28
<FromGitter> <sdogruyol> Make it work then make it fast :smile:
<RX14> there must be a more efficient and cleaner way to write thi logic
<RX14> but i can't see it
<jhass> probably
<RX14> the big if block
<RX14> mainly
<jhass> I'll give it another stare if made mine work and can page it out
<RX14> and @skip_until_end just feels like a hack
triangles has quit [Quit: Leaving]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 240 seconds]
<RX14> jhass, I DID IT
<jhass> \o/
<RX14> i can feel it
<RX14> that feels correct to me
<jhass> @delimiter_buffer.size == @read_delimiter.size trivially true, no?
<RX14> no
<RX14> line 54
<RX14> we resize the buffer to be smaller if we're at the end of the IO
Raimondii is now known as Raimondi
<RX14> then set it on 62
<jhass> but that doesn't reassign @delimiter_buffer
<RX14> shit
<jhass> keep in mind it's a struct
<RX14> yes yes
<RX14> jhass, fixed
<jhass> :)
<RX14> can you follow the logic?
<RX14> jhass, updated the gist with comments
Raimondii has joined #crystal-lang
rolha has quit [Quit: Textual IRC Client: www.textualapp.com]
Raimondi has quit [Ping timeout: 240 seconds]
<jhass> looks good
<jhass> nice work
Raimondii is now known as Raimondi
<RX14> jhass, can you think of any more specs?
<jhass> one with the delimiter at the start and one with it at the end would be good
<RX14> ah yes
<jhass> I wonder if we should consume upto and including the delimiter on .close
<RX14> maybe
<jhass> or at least a .ensure_consumed
<jhass> that you can still call on a pseudo closed one
<RX14> hmmn
<RX14> jhass, those two specs passed
<RX14> which is a good sign
<jhass> cool
<jhass> I guess one where the source stream has two parts and you spawn a second instance on it after the first would be good too
<RX14> well
<RX14> the specs do check the underlying io position after reading fully
<RX14> i think thats enough
<jhass> mh, ok
<RX14> i should really really doccument the two new IOs
<jhass> yes :)
<RX14> but i'll do it tomorrow
<jhass> oh one where there's something looking like the delimiter right at the end
<RX14> jhass, so the delimiter twice
<RX14> make sure it picks the first one
<RX14> or what
<jhass> that's good too, but no I mean an incomplete delimiter at the end
<jhass> make sure it's returned
<RX14> jhass, https://aww.moe/iu3hny.txt does this not count?
<RX14> you mean the end just before the real delimiter
<RX14> right
<RX14> dik
<RX14> idk*
<jhass> whole input "fooz" with "ozb" as delimiter should return "fooz"
<RX14> ahh
<jhass> yup
<RX14> thats enough programming for today
<jhass> :)
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
sandelius has quit [Quit: Textual IRC Client: www.textualapp.com]
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
snsei has quit [Remote host closed the connection]
qard has joined #crystal-lang
<FromGitter> <sdogruyol> Good job :+1:
soveran has joined #crystal-lang
<jhass> RX14: just for fun https://p.jhass.eu/3d.cr didn't turn out all that more readable, I'm still curious how much slower it is though, might benchmark tomorrow
<RX14> jhass, line 121 confuses me
<RX14> oh
<RX14> derp
<RX14> jhass, i think it's more readable
<jhass> just always copies each byte twice
<jhass> so I expect yours to be faster
<RX14> but lines 121/122 confuse me
<RX14> actually
<jhass> I use the ring there as a sliding window onto the stream, each iteration advances the window one further, so we don't need the oldest byte in the window anymore and also know it won't be part of the delimiter, so at that point we give it to the caller
<RX14> ohh
<RX14> shit yes
<jhass> eh, *normalize I/we
<RX14> i get it
<RX14> your one is WAY more readable imo
<RX14> i like it
<RX14> jhass, the comment on line 120 confused more then helped me
<jhass> ok
<RX14> i would say "copy the oldest value in the ring"
<RX14> because it's more obvious what you mean
<jhass> right, it's actually wrong
<RX14> yes
<RX14> it is
<RX14> it's not the last iteration
<RX14> jhass, heh
<jhass> derp
<RX14> fantastic
<RX14> great implementation right there
<jhass> :P
<jhass> there, it's back
<jhass> some stuff similar to https://p.jhass.eu/3e.cr#L256-279 might be good for yours too
<RX14> rip again
snsei has joined #crystal-lang
<jhass> wtf
<jhass> mmh, it runs out of memory
<RX14> lol what are you running this on
<RX14> a toaster?
<jhass> kinda :P
<jhass> just too much stuff on it
<jhass> ah but what do we have systemd for
<jhass> Restart=on-failure
<RX14> docker run --restart=always for me
<jhass> back, let's see for how long
<RX14> i'm running everything in docker containers in a dedicated server from online.net
<RX14> it has 8gb of ram
<RX14> and 20% of that is used by netdata
<RX14> so i can easilly get another gig if I want
<RX14> and it's not even close anyway
<RX14> so i'm very happy with my server
<RX14> i'm very happy with online.net overall really, been almost a year and a half and no outages
<jhass> I plan something similar once I got the money for a more decent box, probably just systemd-nspawn containers instead
<RX14> yeah...
snsei has quit [Ping timeout: 244 seconds]
<RX14> can you run docker in nspawn containers?
<jhass> probably but I see no reason to
<RX14> docker has the networking
<RX14> i need the networking
<jhass> systemd-nspawn can do it already
qard has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
<jhass> and probably KVM/QEMU for the stuff I trust less
<RX14> jhass, well i doubt nspawn networking is as easy as docker
<tilpner> jhass - Do you use any sort of configuration management tool for it?
<RX14> docker is just a magic box
<RX14> which does what I want
<jhass> tilpner: I don't use it yet for the server, locally I just use it as chroot replacement, so I don't need any
<tilpner> Hm. :/
<jhass> didn't really settle yet, perhaps I just do CoreOS or even just archipel
<RX14> my dedicated server is kinda shared between a few friends to split the costs, so i'll probobly run lxc containers with docker inside them
<tilpner> I looked at CoreOS, but it was so much more work, and I didn't really see the benefits for a single machine. *looks at archipel*
<RX14> so each person gets a lxc container
<RX14> and can run docker in it
<RX14> might be a slight waste of ram but i think it's worth
<jhass> so lxc in lxc? :P
<RX14> no
<RX14> not technically
<RX14> but
<RX14> linux containers in lxc
<RX14> ubuntu 16.04 has support for running docker in lxd, so i might just stick to that for the east route
steenuil has joined #crystal-lang
<RX14> anyway, night
<jhass> night
snsei has joined #crystal-lang
soveran has quit [Remote host closed the connection]
willl has quit [Quit: Connection closed for inactivity]
pochito has quit [Ping timeout: 264 seconds]