<btab>
When I think about why methods have refcaps in the first place, my understanding is that you basically shouldn't ask for a ref receiver unless you need one as you're getting permission to write to something when you don't need it.
<btab>
That was my (admittedly very basic) understanding of why funs default to box,
<btab>
So in order to fix retrieval of a value in this example, I've had to open up to requirements from box to ref. That feels idiomatically weird.
<doublec>
It assigns the field to a box rcap and calls the method through that. But shouldn't that be the same as not assigning it to the box rcap since it's box already?
<doublec>
btab: here's an explanation of why it needs to be "fun ref" and why "fun box" is actually wrong
<doublec>
btab: the getThingsStringArrayLiteral() function has the return type defined as "Array[String] ref"
<doublec>
btab: the body tries to return the value of a map, a Array[String] ref.
<doublec>
btab: the returned object is a borrowed item from the map - it's a reference to something held by the map
<doublec>
btab: and a writeable reference at that
<doublec>
btab: but we can't return a writeable reference to something from a box function as it wouldn't then work for 'val'
<doublec>
btab: because that would enable returning a writeable reference to something internal to a val object
<doublec>
btab: and that's why the method needs to be "fun ref" - because we are actually returning a writeable reference to an internal object
<doublec>
btab: make sense?
<btab>
Yes it does, thankyou. This trap was *very* easy to fall into. I'm wondering what the compiler could have done to be more helpful - not sure.
<btab>
I was thinking about how (given this discussion) I'd adapt that function to return a Array[String] val even if the value type in the Map was Array[String] ref.
<btab>
One interesting consequence of this thought process is that it isn't enough to reason 'I want to return an immutable thing therefore my receiver type can be read-only'.
<btab>
It has to have permission in the first place to get at a mutable thing.
<btab>
And the compiler errors are basically driving me to realize (suddenly, and way too late) that I can't just pretend a shared ref is a val. In other words, the compiler's basically waiting for me to realize I need to clone something.
<btab>
Even if the compiler error was pretty obtuse in this case, I like that it's cornered me into reasoning correctly about the permissions in the code.
jemc_ has joined #ponylang
Lordovos has quit [Quit: Page closed]
jemc_ has quit [Ping timeout: 250 seconds]
rurban has joined #ponylang
rurban has quit [Client Quit]
btab has quit [Ping timeout: 260 seconds]
Matthias247 has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]
prettyvanilla has quit [Ping timeout: 250 seconds]
rurban has joined #ponylang
rurban has quit [Quit: Leaving.]
_andre has joined #ponylang
SeanTAllen has quit []
SeanTAllen has joined #ponylang
jemc_ has joined #ponylang
rurban has joined #ponylang
<SeanTAllen>
doublec: there's a bug in assigning to fields and refcaps at the moments. sylvan has an open PR to merge. that might be impacting on your example
c355e3b has joined #ponylang
zevlg has joined #ponylang
unbalanced has joined #ponylang
_andre_ has joined #ponylang
_andre has quit [Ping timeout: 245 seconds]
emilbayes has quit []
emilbayes has joined #ponylang
yggdr has quit [Ping timeout: 260 seconds]
yggdr has joined #ponylang
zevlg has quit [Remote host closed the connection]
rurban has quit [Quit: Leaving.]
cquinn has quit []
cquinn has joined #ponylang
rurban has joined #ponylang
graaff has joined #ponylang
jemc_ has quit [Ping timeout: 258 seconds]
prettyvanilla has joined #ponylang
jemc_ has joined #ponylang
abeaumont has quit [Read error: Connection reset by peer]
beaumonta has joined #ponylang
amclain has joined #ponylang
rurban has quit [Quit: Leaving.]
unbalanced has quit [Ping timeout: 240 seconds]
jemc_ has quit [Ping timeout: 258 seconds]
jemc_ has joined #ponylang
graaff has quit [Quit: Leaving]
theodus has joined #ponylang
rurban has joined #ponylang
rurban has quit [Client Quit]
_andre_ has quit [Quit: leaving]
rurban has joined #ponylang
rurban has quit [Client Quit]
<TwoNotes>
Is there an ongoing discussion somewhere about improvements to the http server package?
rurban has joined #ponylang
<TwoNotes>
I am wondering whether the multi-dispatch feature ("pipelined requests") is worth all the problem it causes
<jemc_>
TwoNotes: I don't think the discussion has been collated anywhere, but we all very much would like the HTTP server to be redesigned for better performance and usability
<jemc_>
if you have ideas for a design, you could open an RFC in our ponylang/rfcs repo with the details
<TwoNotes>
I have been working on some ideas. The way it is now, it can not handle streaming at all, and insists o buffering entire responses in memory, regardless of size, before sending anything to the client
<TwoNotes>
Ok, so there is no existing RFC on this topic?
<jemc_>
on the usability front, I think it's problematic that the incoming request is an `iso` (for the purposes of allowing only a single response) - the fact that it's an `iso` makes it cumbersome to read details from the header and the payload (many have complained about this) - I think I'd rather see the request object be a `val`, but have an `iso` response lambda that you call to send the response
<jemc_>
yeah, there's no existing RFC yet
jemc_ is now known as jemc
<TwoNotes>
I wil read up on the RFC process then
<jemc>
the TLDR is: open a PR that copies the template file and fills in all the sections with your detailed proposal
<TwoNotes>
Current code is also vulnerable to DoS attacks, whether intentional or not. There does not seem to be any throttling
<jemc>
when the discussion has settled, we go to a 1-week final comment period, then the core maintainers vote on it at the following sync call
rurban has left #ponylang [#ponylang]
<jemc>
TwoNotes: (just saw your last sentence) yeah, I agree we should at least have a mechanism for the application to issue backpressure
<TwoNotes>
There was a previous Issue on the TCP package to provide a way for a program to detect whether backpressure had been applied
<TwoNotes>
Or to apply it, so that the TCPCOnnection actor stops reading from the socket
Matthias247 has joined #ponylang
<jemc>
TwoNotes: yes, see `TCPConnection.mute` and `unmute` for the latter
<jemc>
and `TCPConnectionNotify.throttled` and `unthrottled` for the former
<jemc>
main question in my mind would be what is the most useful mechanism for an application to apply backpressure to the http server abstraction
<jemc>
whether that would be something like a `mute`/`unmute`, or a pool of request handlers with a maximum size
<jemc>
latter sounds like it might be easier to manage
<TwoNotes>
On the server side, if it is in the middle of streaming a large media file back to the client, there is no point in accepting additional requests.
<jemc>
also, in terms of an HTTP Server, I think we probably need a `mute`/`unmute` for `TCPServer` to tell it to stop accepting new connections
<TwoNotes>
You would not want to dispatch those requests in any case. You can queue them up to a point, but there has to be a limit. Either they fail with an HTTP status code, or you backpressure the link
<jemc>
that should probably be an RFC of its own - it's an extension of the `TCPConnection.mute`/`unmute` case
<TwoNotes>
Or, just do not implement parallel (pipelined) dispatch at all.
<TwoNotes>
Perhaps a given HTTP Server can decide whether it wants to accept parallel dispatch. If it is going to be serving media files, it could just disable them up gront, and you get simple FIFO processing