- Notifications
You must be signed in to change notification settings - Fork289
Open
Description
Problem
https://docs.raku.org/language/variables#The_augment_declarator
The better usage example has confused some readers:
For a better, and safer example, this is a practical way to create a class module to extend IO::Path by adding a currently missing method to yield the part of the basename left after the extension is removed. (Note there is no clear developer consensus about what to call that part or even how it should be constructed.)
unit class IO::Barename is IO::Path; method new(|c) { return self.IO::Path::new(|c);} use MONKEY-TYPING;augment class IO::Path { method barename { self.extension("").basename; }}
Here is a recent exchange on IRC:
<botato> I'm a little confused reading the documentation for augment at https://docs.raku.org/language/variables[03:05] Raku bridge: <botato> it says "For a better, and safer example, this is a practical way to create a class module to extend IO::Path by adding a currently missing method", does "unit class IO::Barename is IO::Path;" and then "augment class IO::Path {"[03:06] Raku bridge: <botato> if i understand I think the intent was to make IO::Barename that is like IO::Path but with the barename method added[03:07] Raku bridge: <botato> but the example actually monkeypatched the barename method onto IO::Path, was that a mistake and it's supposed to be "augment class IO::Barename" or am I not understanding what's going on?[03:41] Raku bridge: <ugexe> i dont understand what it is trying to say[03:43] Raku bridge: <ugexe> i also don't understand what the example is trying to do
Suggestions
Edited in the light that there is no such thing asbetter and safer augment...
** I suggest that we delete the above paragraph and example entirely **