Re: Illustration of stuff we've been discussing
On May 28, 2009, at 10:27 , John M. Dlugosz wrote: Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Em Qui, 2009-05-28 às 00:24 -0500, John M. Dlugosz escreveu: Please see http://www.dlugosz.com/Perl6/web/info-model-1.html and talk to me about it. The illustratino is cool, but it doesn't take into account the possibility of: @a[0] := $x; Where in the synopses does it say anything like that is possible? := is applied to a _name_. The usual example in the Synopses is with a hash instead of an array, but the same principle applies: %ax := $y; -- brandon s. allbery [solaris,freebsd,perl,pugs,haskell] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon universityKF8NH PGP.sig Description: This is a digitally signed message part
Re: Illustration of stuff we've been discussing
Em Qui, 2009-05-28 às 00:24 -0500, John M. Dlugosz escreveu: Please see http://www.dlugosz.com/Perl6/web/info-model-1.html and talk to me about it. The illustratino is cool, but it doesn't take into account the possibility of: @a[0] := $x; which means that an array is, theoretically, an array of item containers. Consider the following: @a[1] = 0; @a[1] := 1; @a[1] = 2; The first line store 0 in the item container initially created at position 1 of array @a, the second line replaces that container by the value itself, and the third line fails because 1 is a readonly value, not a container, so you can't store into it. Of course this is the theoretical model, and implementations should optimize whenever they can... daniel
Re: Illustration of stuff we've been discussing
Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Em Qui, 2009-05-28 às 00:24 -0500, John M. Dlugosz escreveu: Please see http://www.dlugosz.com/Perl6/web/info-model-1.html and talk to me about it. The illustratino is cool, but it doesn't take into account the possibility of: @a[0] := $x; Where in the synopses does it say anything like that is possible? := is applied to a _name_.
Re: Illustration of stuff we've been discussing
Em Qui, 2009-05-28 às 09:27 -0500, John M. Dlugosz escreveu: Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Em Qui, 2009-05-28 às 00:24 -0500, John M. Dlugosz escreveu: Please see http://www.dlugosz.com/Perl6/web/info-model-1.html and talk to me about it. The illustratino is cool, but it doesn't take into account the possibility of: @a[0] := $x; Where in the synopses does it say anything like that is possible? := is applied to a _name_. I don't recall if it is in the synopsis... but it is a general expectation, and, I think, this was discussed in IRC for a long time. But certainly is a good time to either put on the spec or drop the expectation... daniel
Re: Illustration of stuff we've been discussing
On Thu, May 28, 2009 at 01:06:18PM -0300, Daniel Ruoso wrote: : Em Qui, 2009-05-28 às 09:27 -0500, John M. Dlugosz escreveu: : Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: : Em Qui, 2009-05-28 às 00:24 -0500, John M. Dlugosz escreveu: : Please see http://www.dlugosz.com/Perl6/web/info-model-1.html : and talk to me about it. : The illustratino is cool, but it doesn't take into account the : possibility of: :@a[0] := $x; : Where in the synopses does it say anything like that is possible? := is : applied to a _name_. : : I don't recall if it is in the synopsis... but it is a general : expectation, and, I think, this was discussed in IRC for a long time. : But certainly is a good time to either put on the spec or drop the : expectation... It pretty much has to be that way, if we want to represent lexical pads with built-in data types. Our symbol tables are simply hashes, for instance. (There may be many pads corresponding to a given lexical symbol table, however, since all clones of a closure share a single symbol table but each have their own pad of values.) Basically, (ignoring STD's definition of name) I view @a[0] as a name, in the sense of identifying a unique object. It just happens to contain navigational elements like a URL. Of course, if @a is declared to hold only a compact array of native types, binding a pointer into one of the entries isn't going to fly. But we're defining the differences between the behavior of $a and @a in terms of how it desugars in context, so there's no need for the actual binding to distinguish any extra levels of indirection. All it needs to know is where to poke the pointer to the object. And normally @a contains a list of poke-able pointers, so @a[0] := $x is fair game. Larry
Re: Illustration of stuff we've been discussing
Larry Wall larry-at-wall.org |Perl 6| wrote: Basically, (ignoring STD's definition of name) I view @a[0] as a name, in the sense of identifying a unique object. It just happens to contain navigational elements like a URL. OK, that that might be what was meant in the synopses when it was penned 9 years ago, before formal terminology was better fixed. Of course, if @a is declared to hold only a compact array of native types, binding a pointer into one of the entries isn't going to fly. One of my thoughts, exactly. But we're defining the differences between the behavior of $a and @a in terms of how it desugars in context, so there's no need for the actual binding to distinguish any extra levels of indirection. All it needs to know is where to poke the pointer to the object. And normally @a contains a list of poke-able pointers, so @a[0] := $x is fair game. And if $x is the wrong type, it errors. So if @a is the wrong type in a larger sense of not being able to support that, it errors. E.g. it is a compact array, or some user-defined collection, or is otherwise read-only. --John
Re: Illustration of stuff we've been discussing
Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Em Qui, 2009-05-28 às 00:24 -0500, John M. Dlugosz escreveu: Please see http://www.dlugosz.com/Perl6/web/info-model-1.html and talk to me about it. The illustratino is cool, but it doesn't take into account the possibility of: @a[0] := $x; which means that an array is, theoretically, an array of item containers. Consider the following: @a[1] = 0; @a[1] := 1; @a[1] = 2; Syntax aside, and what the spec actually says about := aside, I do agree that a container must be able to cough up an lvalue for any of its addressable content individually. That works (in this model) because of how items are intimatly tied with lvalues, and the way parameters are bound and what declaring an lvalue return does (returning is the same as passing, as they are both Captures). Anyway, I'll explain my thoughts on that in detail this weekend. --John
Re: Illustration of stuff we've been discussing
Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Em Qui, 2009-05-28 às 09:27 -0500, John M. Dlugosz escreveu: Daniel Ruoso daniel-at-ruoso.com |Perl 6| wrote: Em Qui, 2009-05-28 às 00:24 -0500, John M. Dlugosz escreveu: Please see http://www.dlugosz.com/Perl6/web/info-model-1.html and talk to me about it. The illustratino is cool, but it doesn't take into account the possibility of: @a[0] := $x; Where in the synopses does it say anything like that is possible? := is applied to a _name_. I don't recall if it is in the synopsis... but it is a general expectation, and, I think, this was discussed in IRC for a long time. But certainly is a good time to either put on the spec or drop the expectation... daniel I agree with you there. This Information Model will handle putting an Item Container into a primitive slot in a collection, and it just works after that. This seems to be a useful way of pinning down the abilities and limitations of iterators and modifying containers while iterating on them, in a way that is implementation-agnostic but well defined. So, there should be an easy way to do that. Extending the meaning of := to work in more general terms, create an lvalue that may be aliased, assigned to, etc. initially holding the RHS as its value might be just what people expect it to do, given the symmetry between symbol tables and other collections. But, if you limit the availability of := to declaration-time only (or pre-declared to accept that, but who needs it?) to allow the compiler to optimize based on *knowing* the container type, then a different syntax might be better, since you can make it work on a symbol table entry (alias something else) without actually binding the symbol. Just thinking out loud. Wait for the picture. --John
Illustration of stuff we've been discussing
Please see http://www.dlugosz.com/Perl6/web/info-model-1.html and talk to me about it. --John