Yes. This trick is handy but totally confusing. I think that self in playground should return nil. because self only makes sense in method body and inspector pane.
Stef On Sat, Jan 28, 2017 at 4:50 AM, Ben Coman <b...@openinworld.com> wrote: > > > On Sat, Jan 28, 2017 at 4:11 AM, stepharong <stephar...@free.fr> wrote: > >> I should tell you that I do not like it at all. >> Hey students inside comments self means the class and outside the >> instance! WTF? >> >> I think that we should have another kind of pseudo variable but not self. >> > > So in comments on the instance-side should we have pseudo variable "class" > or "myclass" ? > But then do students try to use that in the playground? > > Maybe instance-side comments should have no pseudo variable, > and use the class directly. After all, comments have an absolute position > in the hierarchy. > Its not like you can evaluate the comment from a subclass. > > > On class-side "self" seems okay in comments, since it means the same thing > as in code. > Perhaps it even draws attention of students that the class is itself an > object. > > cheers -ben > > >> >> >> >> Hi all, >> >> in Nautilus, `self` is always the current class instance. This is great >> for coding class side methods because we can test code fragments live in >> the editor, but for instance side methods I have not seen the usefulness of >> it. At times it can even be confusing and cause errors since a "print it" >> of it looks quite like an instance (`a Listener` vs `Listener`). >> >> Is there a rationale why `self` in instance view does not raise an error >> or is nil? And, more importantly, could there be a way to set it to a >> specific value (= can we browse a class with self bound to an specific >> instance). >> >> >> In Pharo 6 if you tag a class method with >> >> <sampleInstance> >> ... >> ^ return the instance >> >> then you get automatically an icon to get an inspector on the instance. >> From there you can do whatever you want. >> >> >> This would resemble programming in the debugger, but provide the overview >> that a class browser provides. >> >> cheers, >> Siemen >> >> >> >> >> >> -- >> Using Opera's mail client: http://www.opera.com/mail/ >> > >