I spent the weekend playing with Yeti, and I'm very impressed. It is a
*nice* language.
To have something to work on, I cloned the snake game from Learning
Clojure, which went almost perfectly. I do have one question, though.
I probably missed it in the documentation, but how do you access a
method of a class' superclass?
On Tue, 5 Jul 2011, Tommy McGuire wrote: > I spent the weekend playing with Yeti, and I'm very impressed. It is a > *nice* language.
> To have something to work on, I cloned the snake game from Learning > Clojure, which went almost perfectly. I do have one question, though. > I probably missed it in the documentation, but how do you access a > method of a class' superclass?
> Looked at the comments now, member? is contains in the library (and yes,
> it would've been better named contains?).
> ...
Thanks for your comments! I was updating my code and had a little
problem with the super#paintComponent(g) call and the new yeti.jar.
snake.yeti:142:14: Non-public method
javax.swing.JComponent#paintComponent cannot be accessed from
different package ()
It looks like the paintComponent method in javax.swing.JComponent (the
superclass of JPanel) is protected. It should be accessible from my
subclass of JPanel, right?
Also, I am wondering about the definition of butLast:
butLast lst =
case lst of
[_]: [];
h :: t: h :: butLast t;
_: [];
esac;
If I change it to be:
butLast lst =
case lst of
[] : [];
[_] : [];
h :: t : h :: butLast t;
esac;
I get an error: "1:10: Partial match: []".
I can see where your version is guaranteed to match, because the last
case is a default. However, I think mine is exhaustive. What is wrong
with it?
>> Looked at the comments now, member? is contains in the library (and yes, >> it would've been better named contains?). >> ...
> Thanks for your comments! I was updating my code and had a little > problem with the super#paintComponent(g) call and the new yeti.jar.
> snake.yeti:142:14: Non-public method > javax.swing.JComponent#paintComponent cannot be accessed from > different package ()
> It looks like the paintComponent method in javax.swing.JComponent (the > superclass of JPanel) is protected. It should be accessible from my > subclass of JPanel, right?
> Also, I am wondering about the definition of butLast:
> butLast lst = > case lst of > [_]: []; > h :: t: h :: butLast t; > _: []; > esac;
> If I change it to be:
> butLast lst = > case lst of > [] : []; > [_] : []; > h :: t : h :: butLast t; > esac;
> I get an error: "1:10: Partial match: []".
> I can see where your version is guaranteed to match, because the last > case is a default. However, I think mine is exhaustive. What is wrong > with it?
Yes, your match is exhaustive, but the pattern analyzer isn't currently smart enough and errs on the safe side (requiring a match-all pattern on list matches). In practice it's usually possible to organize the pattern that way.
On Thu, 7 Jul 2011, Madis wrote: > On Wed, 6 Jul 2011, Tommy McGuire wrote:
>> Thanks for your comments! I was updating my code and had a little >> problem with the super#paintComponent(g) call and the new yeti.jar.
>> snake.yeti:142:14: Non-public method >> javax.swing.JComponent#paintComponent cannot be accessed from >> different package ()
>> It looks like the paintComponent method in javax.swing.JComponent (the >> superclass of JPanel) is protected. It should be accessible from my >> subclass of JPanel, right?
> >> It looks like the paintComponent method in javax.swing.JComponent (the
> >> superclass of JPanel) is protected. It should be accessible from my
> >> subclass of JPanel, right?
> On Tue, 5 Jul 2011, Tommy McGuire wrote:
> > Specifically, I created a subclass of JPanel whose implementation of
> > paintComponent needs to call the superclass' paintComponent.
> It wasn't implemented, but I implemented it now. ;)