It wasn't implemented, but I implemented it now. ;)
Just use super#fobar(...) in some method.
https://github.com/mth/yeti/commit/0a7b745cf9da839fcac0c03b9065518263549e18
The http://linux.ee/~mzz/yeti/yeti.jar has been updated, too.
> If you want to check out my code, it's at http://www.crsr.net/files/snake.yeti.
> I also wrote some comments about it at http://maniagnosis.crsr.net/2011/07/snakes-on-yeti.html.
> I would welcome any suggestions or corrections.
Looked at the comments now, member? is contains in the library (and yes,
it would've been better named contains?).
The list destructuring pattern matching is there, but you must use case of to do it.
butLast lst =
case lst of
[_]: [];
h :: t: h :: butLast t;
_: [];
esac;
There is a short-hand for creating new structures from existing ones:
turn snake newdir =
{ dir = newdir,
body = snake.body,
color = snake.color };
Could be written as:
turn snake dir =
snake with {dir};
The {dir} there is equivalent to {dir = dir}, and this can be used
everywhere, so:
{ x = x, y = y, w = w, h = h } = pointToScreenRec pt;
can be written as
{ x, y, w, h } = pointToScreenRec pt;
Hoping this helps ;)
> On Jul 6, 8:31�am, Madis <ma...@cyber.ee> wrote:
>> On Tue, 5 Jul 2011, Tommy McGuire wrote:
>>> If you want to check out my code, it's athttp://www.crsr.net/files/snake.yeti.
>>> I also wrote some comments about it athttp://maniagnosis.crsr.net/2011/07/snakes-on-yeti.html.
>>> I would welcome any suggestions or corrections.
>>
>> 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?
I'll look into it.
> 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 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?
>
> I'll look into it.
Should be fixed now.