<anthonybullard>
And yes, in debug mode, I received the same result
<anthonybullard>
You'll notice I switch to an if, still same thing, both arms are being evaluated
<anthonybullard>
I have to assume I am missing some incredibly obvious
nisanharamati has quit [Quit: Connection closed for inactivity]
<jemc>
which line's try/if are you talking about in this example?
<jemc>
(anthonybullard: ^)
<jemc>
(when I run your example locally, I just see "Listening on port 8989", and I'm not sure what I'm supposed to see)
<anthonybullard>
ah, so it's a TCP listener
<anthonybullard>
so you have to cat out the file I have a listing for in the comments below
<anthonybullard>
cat it out to the tcp port
<jemc>
ah, I see - I was ignoring the comments, assuming they were stray code that was commented out
<jemc>
so, what I suspect is happening is that your `received` handler is running more than once - once with a correct parse, and once with an inability to parse
<jemc>
note that, with TCP sockets, there's no guarantee in what chunks the bytes will arrive
<jemc>
so if you're expecting the five-byte string `["hello"]`, you might instead get `["hell", "o"]` or `["he", "l", "lo"]`
<jemc>
what's probably happening is you're getting a stray newline in or something in another chunk
<jemc>
after parsing the main bulk
<jemc>
what you probably want to do on a failed parse is to append the bytes into a buffer in a field, so that they will accumulate and persist between calls until the parse succeeds
<jemc>
`buffered.Reader` is intended for this purpose
jemc has quit [Ping timeout: 244 seconds]
<anthonybullard>
thanks @jemc!
<anthonybullard>
I'll look at this
<anthonybullard>
Hm, I'm not so sure about that theory jemc
<anthonybullard>
You'll see that prints in both branches run, and that the function overall only is called once
<anthonybullard>
And in that single call, all the data is delivered whole
<anthonybullard>
But even more interesting is that the print from inside the try(which should not be reach), happens in the middle of the print from before the try
<anthonybullard>
Last bit of context, it is only prints that run after the error in the try. Mutating idx does not actually happen, even though it is between where the error is thrown, and the print
<anthonybullard>
jemc: I was, of course, wrong. But there is something not quite right with `print`, but I am probably wrong about that as well
endformationage has quit [Ping timeout: 268 seconds]
<vaninwagen>
What is not quite right with print? anthonybullard is it the order in which you see outputs on the console?
<Candle>
jemc: expecting bytes to arrive in odd chunks: https://github.com/CandleCandle/text-reader Attempting to build a byte-stream-to-lines that doesn't rely on `Array.find()?`
<Candle>
vaninwagen: Recall one of our discussions about the problems with the HTTP parser and it's relying on the partial function `Reader.line()?`? There's an attempt to not use partial functions to replace that one.
<Candle>
It's *nasty* currently, not all the tests pass, and I think I've got all the edge cases in the tests. *shakes fist at multi-byte separators!*
<vaninwagen>
Nice
<Candle>
One of the things that I'm quite used to doing is refactoring to 'introduce class|method' to encapsulate data. I'm finding that relatively hard with pony as when you do that, you almost always end up aliasing something, which, in the context of the code is relatively safe, but provably unsafe.
<Candle>
e.g. in the above, I wanted the `BufferElement` to have a `append_to(str)` (aids testing as that function can be tested in isolation) and be able to return a val String from the calling function. There was an annoying pattern of doing something along the lines of `str' = element.append_to(consume str); str = str'` which looked confusing and introduced multiple other problems.
<Candle>
Have I missed any obvious edge-cases in my tests? I havn't seen any refactoring notes yet, any ideas?
<vaninwagen>
I am gonna have a look tomorrow. Totally swamped right now
<Candle>
It's certainly not complete. (won't handle cases where the \r\n is split across two arrays)
CcxWrk has quit [Read error: Connection reset by peer]
CcxWrk has joined #ponylang
Nawab has joined #ponylang
CcxWrk has quit [Ping timeout: 250 seconds]
<anthonybullard>
vaninwagen: yes, is this a known problem?
jemc has joined #ponylang
CcxWrk has joined #ponylang
endformationage has joined #ponylang
jemc has quit [Ping timeout: 250 seconds]
nisanharamati has joined #ponylang
jemc has joined #ponylang
travis-ci has joined #ponylang
<travis-ci>
ponylang/ponyc#5499 (master - 2fab2f8 : [Main]): The build was broken.