jemc changed the topic of #ponylang to: Welcome! Please check out our Code of Conduct => https://github.com/ponylang/ponyc/blob/master/CODE_OF_CONDUCT.md | Public IRC logs are available => http://irclog.whitequark.org/ponylang | Please consider participating in our mailing lists => https://pony.groups.io/g/pony
Praetonus has quit [Quit: Leaving]
jemc has quit [Ping timeout: 256 seconds]
jemc has joined #ponylang
jemc has quit [Ping timeout: 264 seconds]
graaff has joined #ponylang
<emilbayes> is anyone else having issues with HEAD on master of ponyc?
<emilbayes> I'm trying to follow the first example in Pony tutorial, but get an error about Docstring in builtin.pony
<emilbayes> nvm, i'd been messing with ponyc. Sorry!
<TwoNotes> I am confused as to why a function call is considered to create an alias for the receiver.
<TwoNotes> Yet fetching a value from a field does not create an alias
<TwoNotes> 2. If a 'match' has a pattern for all members of a union type, why is there still a phantom 'else None' assumed?
graaff has quit [Quit: Leaving]
TwoNotes1 has joined #ponylang
TwoNotes1 has left #ponylang [#ponylang]
<SeanTAllen> re 2: because we don't exhaustive match yet.
<SeanTAllen> re the first TwoNotes, i'd need to see an example.
<TwoNotes> That was for the match one.
<TwoNotes> I got around it by putting one of the alternatives as the else clause
<TwoNotes> SeanTAllen, the message suggests that calling a function creates an alias of the receiver. I am wondering why it would do that. Passing it as a parameter I would understand
<TwoNotes> foo.n=3 is OK, but foo.set_n(3) is not.
<TwoNotes> Perhaps there is a "this" created inside the execution of the function? And that is a copy of the receiver?
<TwoNotes> This makes it impossible to call multiple methods on an iso
jemc has joined #ponylang
<TwoNotes> This convoluted workaround is accepted https://gist.github.com/pdtwonotes/ec591158d16614c0076808eb4979d11f
<SeanTAllen> Why do you want an iso field?
<SeanTAllen> Whats the value in that compared to a ref?
<TwoNotes> It is eventually going to be sent to another actor
<TwoNotes> That is, the Foo object is going to be sent
<SeanTAllen> So you are going to do a destructive read on it?
<TwoNotes> What will happen is it will get converted to a val, then sent
<SeanTAllen> let old_foo = foo = Foo
<SeanTAllen> something.some_method(consume old_foo)
<SeanTAllen> ?
<TwoNotes> I was just going to do something.some_method( recover val foo end)
<SeanTAllen> so, you are using an `iso` as a `trn` ?
<SeanTAllen> or am i not understanding?
<TwoNotes> I am calling various methods to put values into this object. So it has to be mutable. Then this object gets handed to another actor.
<TwoNotes> Hmm, trn allows a single writer, right?
<SeanTAllen> yes
<SeanTAllen> what you are describing afaict is the `trn` use case
<TwoNotes> So I would make the function be fun trn set_n(m)?
<SeanTAllen> no
<SeanTAllen> you want ref
<SeanTAllen> you need a mutable one
<SeanTAllen> in your example
<SeanTAllen> there is nothing about Foo that says "this has to be an iso"
<SeanTAllen> what you have is something that needs to be mutable
<SeanTAllen> `ref`
<SeanTAllen> `iso` is a subtype of ref
<SeanTAllen> `trn` is too
<TwoNotes> So I can recover a ref to iso?
<SeanTAllen> the only 4 things you should ever need there are `` for box, `ref`, `val` or `tag`
<SeanTAllen> no
<SeanTAllen> you cant recover to a subtype
<TwoNotes> So if I have a Foo ref, how do I sent it in a 'be' call?
<SeanTAllen> recovery has nothing to do with the viewpoint adaptation
<SeanTAllen> You can send a foo ref
<SeanTAllen> sorry `cant`
<SeanTAllen> not can
<SeanTAllen> but
<SeanTAllen> that doesnt mean you do
<SeanTAllen> you want `fun ref` not `fun iso`
<SeanTAllen> I'm not sure what you are trying to do with that set_n
<SeanTAllen> `consume this` is non sensical
<TwoNotes> 'set_n' is a standin in my example for "functions that mutate Foo"
<jemc> SeanTAllen: actually, `consume this` is used a few times in the standard library, inside `fun iso` functions
<SeanTAllen> example jemc ?
<jemc> `String._append`, `net/http.Payload.respond`
<SeanTAllen> im looking at them, i find them both rather odd
<TwoNotes> I think it is just to keep the compiler happy. If the called function does not pass 'this' on anywhere it should just work
<SeanTAllen> i see what they are doing, but I find it rather odd, jemc.
<TwoNotes> Look at my gist again. I put in more to show what I am doing. https://gist.github.com/pdtwonotes/ec591158d16614c0076808eb4979d11f
<SeanTAllen> I still dont understand what Foo.set_n is supposed to be doing
<TwoNotes> I agree that 'consume this' is nonsensical.
<TwoNotes> set_n is mutating the Foo object
<TwoNotes> But putting in the nonsensical 'consume this' keeps the compiler happy. Ergo, I think the compiler needs to be smarter about 'this'
<TwoNotes> 'this' goes out of scope at the end of a fun call. It evaporates. Imagine if the function call was expanded in-line by the optimizer.
<SeanTAllen> I don't understand why you wouldn't create a new Foo
<SeanTAllen> but this is very off topic from your question
<TwoNotes> "Foo" in my case is a massive object with lots of fields in it. I make multiple calls putting info in those fields. Then I want to send a 'val' version of it to another actor
<SeanTAllen> looking at String.add in the standard library, I see why it's doing it. I still find it to be an odd API in that standard library case.
<SeanTAllen> TwoNotes: I think you want a `trn`
<TwoNotes> Ah, since the 'this' inside the function is only read from?
<SeanTAllen> I don;t follow
<TwoNotes> The receiver is used to locate the instance of Foo to be operated on. The "n=m" is really this.n = m
<TwoNotes> It is reading from 'this'
<SeanTAllen> Still don't understand. I'm looking at your gist and I don't see anything about locating instances.
<TwoNotes> It is inherent in calling a method on an object!
<SeanTAllen> I don't understand
<SeanTAllen> If you want to create a mutable object that can later be made immutable and sent to another actor, `trn` is what you want.
<SeanTAllen> dinner time for me though. stepping away.
<TwoNotes> So the "trn" goes on the Foo constructor?
<TwoNotes> So trn on the constructore, ref on the functions, and the other actor will get it as a val
<SeanTAllen> TwoNotes:
<SeanTAllen> you don't need to put `trn` on anything. Just recover to it when you create the object
<SeanTAllen> but if you want to but `new trn create` and have it default to `trn` you can.
jemc has quit [Ping timeout: 265 seconds]
_whitelogger has joined #ponylang
amclain has joined #ponylang