'CALL-ME' Math problem?
Hi All, Math problem: x = 60÷5(7−5) raku -e 'say 60÷5(7−5)' No such method 'CALL-ME' for invocant of type 'Int' in block at -e line 1 Seems raku does not like the (). How do I fix this and maintain the flow and look of the equation? -T The correct answer is 24
Re: 'CALL-ME' Math problem?
Just because mathematics allows an implied multiplication doesn't mean Raku does -- in fact I can't think of any programming language which does. You need to stick an explicit multiplication operator ('*' or '×') between the 5 and the left parenthesis. The reason for the error message is that adding parentheses after something is interpreted as trying to invoke a function. Callable objects such as functions have a CALL-ME method which is what is invoked to call the function. An integer lacks such a method, since it isn't callable. On Tue, 2 Mar 2021 at 19:13, ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > > Hi All, > > Math problem: > x = 60÷5(7−5) > > raku -e 'say 60÷5(7−5)' > No such method 'CALL-ME' for invocant of type 'Int' >in block at -e line 1 > > Seems raku does not like the (). How do I fix this > and maintain the flow and look of the equation? > > -T > > The correct answer is 24 > > >
Rakudo Star 2021.02.1
Good morning/afternoon/evening Rakoons! Sadly, there was no Rakudo/MoarVM/NQP release in January, so Rakudo Star is going to use the next best thing, the release from February. This change was just pushed, and is ready to use. This is the first release that appears on GitHub as an actual release[1], too, using a new GitHub workflow. This could probably be used to create binary releases for Mac and Windows users too, if someone has some spare time and passion. The release is always available on rakudo.org as well, of course[2]. Happy hacking everyone~ [1]: https://github.com/rakudo/star/releases/tag/2021.02.1 [2]: https://rakudo.org/dl/star/rakudo-star-2021.02.1.tar.gz -- With kind regards, Patrick Spek www: https://www.tyil.nl/ mail: p.s...@tyil.nl pgp: 1660 F6A2 DFA7 5347 322A 4DC0 7A6A C285 E2D9 8827 git:https://git.tyil.nl/ signature.asc Description: PGP signature
Re: 'CALL-ME' Math problem?
On Tue, 2 Mar 2021, 08:13 ToddAndMargo via perl6-users, mailto:perl6-us...@perl.org>> wrote: Hi All, Math problem: x = 60÷5(7−5) raku -e 'say 60÷5(7−5)' No such method 'CALL-ME' for invocant of type 'Int' in block at -e line 1 Seems raku does not like the (). How do I fix this and maintain the flow and look of the equation? -T The correct answer is 24 On 3/2/21 12:16 AM, Simon Proctor wrote: You need to put in the multiplication sign. Hi Simon and Richard, Now I feel dumb! $ raku -e 'say 60÷5*(7−5)' 24 Thank you! The formula is an example of left to right precedence. -T
Re: 'CALL-ME' Math problem?
>> >> Hi All, >> >> Math problem: >> x = 60÷5(7−5) >> >> raku -e 'say 60÷5(7−5)' >> No such method 'CALL-ME' for invocant of type 'Int' >> in block at -e line 1 >> >> Seems raku does not like the (). How do I fix this >> and maintain the flow and look of the equation? >> >> -T >> >> The correct answer is 24 >> >> On 3/2/21 12:17 AM, Richard Hainsworth wrote: no operator between '5' & '(' That is mathematical shorthand. Introducing such shorthand into a programming language leads to ambiguities. I'm not aware of any formal system that implies a '*' in such a situation. Richard On 02/03/2021 08:12, ToddAndMargo via perl6-users wrote: $ raku -e 'say 60÷5*(7−5)' 24 :-)
Alternative view of Raku Documentation
I've just passed a milestone in the development of a suite of modules for rendering a collection of POD6 content files. Please take a look at http://raku.finanalyst.org and especially http://raku.finanalyst.org/search.html Please let me know whether you find the search interface easier than the one on the official site. (I will be updating based on feedback. Eg., I will be showing links and visited links more clearly, but not with blue/purple of standard HTML) Both search functions (the official one, and mine) rely on the same underlying information, but it is presented in a different way. I wanted (a) more context when searching, (b) I want previous searches to be retained in case the place I went to does not have the information was looking for. Please also bear in mind that this is a system still being developed. So there are some wrinkles: 1: There are numerous places in the official Raku docs where links target 'virtual' files. These virtual files do not exist in the Raku/docs directory, but are generated by the software developed to render the POD6 files, namely Documentable. Personally, I think having links to virtual files is fragile, and it does make the development of an alternative system of viewing the docs more difficult. 2: The inheritance diagrams in the standard documentation system are not cited in the official Raku docs, but are "sewn in" by Documentable based on a single text file that describes relationships. The reasons I developed this new system? - I want to create a Blog site, a site for translations from English to Welsh, and a site for my business that rely mostly on Raku, not php. - The underlying content of most CMS suites seems to be MarkDown. But MarkDown does not allow for any meta data to be attached to text. POD6 is both simple to write, but it also allows for meta data to be attached to paragraphs, headers, blocks. You can see some of this potential by clicking on the Collection button at raku.finanalyst.org - I'm not entirely happy with the Documentable/Pod::To::HTML modules that are used to render Raku Documentation, and I hate it when people criticise things without providing some systematic alternative. So here's an alternative. I have more to say about Module documentation, but that involves another topic.
Module Documentation
Hi, I want to create a system that will show documentation about Raku Modules that I have installed. There does not seem to be a Documentation standard, or best practice, for Raku modules. Hence the following post. In the Modules documentation in the Language section of the Raku documentation, there is a single mention of README.md, but only that it is needed by github. There is no indication about what should be in README.md As a user of Raku, this does not matter much to me in practice, as when I need to understand something, I look at the code on the repository. But it can be a hassle going to Modules.raku.org, finding the module, going to the repo, finding where the information is, etc. I do NOT try and find the information that has been installed by zef because the location names are not human friendly. I understand the reasoning there, and do not suggest any change. But it is not easy to find documentation on locally installed modules, even though the information is there. Even the "zef --open browse source" command opens a browser to the internet repo, not to the local installation. There is no "zef documentation entity" or "zef README entity" command. I am NOT complaining about zef because the problem is not with zef, per se, but with the absence of a documentation standard (I think). I wanted to incorporate a page with documentation of modules in the Collection-Raku-Documentation system I have just released. But I do not see how to do this. Most Raku modules have a README.md, which is required because of github requirements. Although the README's of some modules leave a great deal to be desired. Many modules have extensive POD6 inside the main 'lib/module.pm6' file (where 'module' obviously is a placeholder for this email). There is an issue on the GTK::Simple repo, which I am now the maintainer of, for more documentation. Actually, I learnt how to use GTK::Simple by looking at the examples in the repo, which have lots of explanation. But the README.md is appalling. However, an unanswered question is where would I put a documentation file when I write it, so that it is useful for users wanting to understand more. In the modules I am now developing, I have a README.pod6 file, which I convert to the README.md file for github using a GUI tool in Raku::Extraction. The advantage of this is that the README.pod6 can have links to other pod6 files. My suggestion is that some formal decision is made about documentation for Raku modules, that some documentation good practices are put together and included in the Modules page. My suggestion is that documentation should be in one of the following: - the main module, defined (perhaps) as the pm6 file with the same name as the Distribution name - a README.pod6 in the root - a POD6 file pointed to by META6.json, eg a META6.json key that looks like: "documentation": "/lib/MyModule.pm6" or something.
Re: 'CALL-ME' Math problem?
Kevin Pye wrote: > Just because mathematics allows an implied multiplication doesn't mean Raku > does -- in fact I can't > think of any programming language which does. As a (potentially) interesting side note, while Raku doesn't provide implied multiplication, it _is_ one of the few programming languages that would let you implement something very similar yourself: sub infix:«\c[INVISIBLE TIMES]» { $^a × $^b } This would let you write `say 60÷5(7−5)` (with an invisible character between the `5` and the `(` ) and get the expected result. Doing so would, of course, be a very bad idea. But still, you _could_. Source: https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/
Re: 'CALL-ME' Math problem?
> Doing so would, of course, be a very bad idea. But still, you _could_. Something of an understatement, I think. :-)* Seriously, this made me wonder if inscrutable error messages might be clarifed by a (reverse) trace of the last few steps in parsing. That would show you what the compiler thought ir was doing. Would that be a) reasonably practical to implement, and b) sufficiently useful to justify the effort?
Re: Module Documentation
Richard Hainsworth wrote: > My suggestion is that some formal decision is made about documentation for > Raku modules, that some > documentation good practices are put together and included in the Modules > page. I think that this is a great idea (and that your suggestions afterwords are a good start). Maybe the next step would be to open an issue in the Problem Solving repo[0]? To my knowledge, that's the main way for the Raku community to make formal decisions of this nature. [0]: https://github.com/Raku/problem-solving
Re: 'CALL-ME' Math problem?
But why do that when you can add a CALL-ME to the number classes that does multiplication? 😇 Int.^add_fallback( {$^i.defined && $^m eq 'CALL-ME'}, -> $, $ { * * * } ); say 5(4); # 20 On Tue, Mar 2, 2021, 09:08 Daniel Sockwell wrote: > Kevin Pye wrote: > > Just because mathematics allows an implied multiplication doesn't mean > Raku does -- in fact I can't > > think of any programming language which does. > > As a (potentially) interesting side note, while Raku doesn't provide > implied multiplication, it _is_ > one of the few programming languages that would let you implement > something very similar yourself: >sub infix:«\c[INVISIBLE TIMES]» { $^a × $^b } > > This would let you write `say 60÷5(7−5)` (with an invisible character > between the `5` and the `(` ) > and get the expected result. > > Doing so would, of course, be a very bad idea. But still, you _could_. > > Source: > > https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/ >
Re: 'CALL-ME' Math problem?
On Tue, Mar 2, 2021 at 4:08 PM Matthew Stuckwisch wrote: > But why do that when you can add a CALL-ME to the number classes that does > multiplication? 😇 > > Int.^add_fallback( > {$^i.defined && $^m eq 'CALL-ME'}, > -> $, $ { * * * } > ); > > say 5(4); # 20 > say 5(5)² # 625… oops! 😀 but say 5(5²) # 125 ok > On Tue, Mar 2, 2021, 09:08 Daniel Sockwell > wrote: > >> Kevin Pye wrote: >> > Just because mathematics allows an implied multiplication doesn't mean >> Raku does -- in fact I can't >> > think of any programming language which does. >> >> As a (potentially) interesting side note, while Raku doesn't provide >> implied multiplication, it _is_ >> one of the few programming languages that would let you implement >> something very similar yourself: >>sub infix:«\c[INVISIBLE TIMES]» { $^a × $^b } >> >> This would let you write `say 60÷5(7−5)` (with an invisible character >> between the `5` and the `(` ) >> and get the expected result. >> >> Doing so would, of course, be a very bad idea. But still, you _could_. >> >> Source: >> >> https://perl6advent.wordpress.com/2017/12/01/the-grinch-of-perl-6-a-practical-guide-to-ruining-christmas/ >> > -- Fernando Santagata
Re: 'CALL-ME' Math problem?
Not in this case. The error happens at run-time. Syntactically the expression is a valid one because `5(...)` is interpreted as an invocation. Raku implements invocation protocol a part of which is method 'CALL-ME' defined on a class: class Foo { method CALL-ME(|c) { say "Foo invoked with {c.raku}" } } Foo(42, :foo(13)); Foo.new().(); Note that the protocol works for both a type object and its instantiation. This is what is basically happens in the case of `5(...)`: it falls back to `Int` and tries to invoke `CALL-ME` on it. One could say that it makes no sense, but an example with adding a fallback method has been already provided here. And here is another one follows: my $foo = 5 but role { method CALL-ME(|c) { say "Int with ", c.raku } }; $foo(13); The currently produced error, unfortunately, is confusing for beginners. But as soon as one gains more experience with Raku it makes clear sense instantly. Best regards, Vadim Belman > On Mar 2, 2021, at 9:26 AM, Parrot Raiser <1parr...@gmail.com> wrote: > >> Doing so would, of course, be a very bad idea. But still, you _could_. > > Something of an understatement, I think. :-)* > > Seriously, this made me wonder if inscrutable error messages might be > clarifed by a (reverse) trace of the last few steps in parsing. That > would show you what the compiler thought ir was doing. > > Would that be a) reasonably practical to implement, and b) > sufficiently useful to justify the effort? >
Re: Module Documentation
On Tue, Mar 2, 2021 at 08:42 Daniel Sockwell wrote: > Richard Hainsworth wrote: > > My suggestion is that some formal decision is made about documentation > for Raku modules, that some > > documentation good practices are put together and included in the > Modules page. > I agree that's a good idea, but I think it needs to be part of a larger idea of module best practices in general, including testing, and maybe a "green" check as a module that approved as "meets standard" or something like that.
Re: Module Documentation
On Tue, Mar 2, 2021 at 11:13 AM Tom Browder wrote: > On Tue, Mar 2, 2021 at 08:42 Daniel Sockwell > wrote: > >> Richard Hainsworth wrote: >> > My suggestion is that some formal decision is made about documentation >> for Raku modules, that some >> > documentation good practices are put together and included in the >> Modules page. >> > > I agree that's a good idea, but I think it needs to be part of a larger > idea of module best practices in general, including testing, and maybe a > "green" check as a module that approved as "meets standard" or > something like that. > Like the Perl 5 module: https://metacpan.org/pod/Test::Kwalitee
Re: Alternative view of Raku Documentation
This is some very nice work, of course. I was wondering how difficult it would be to support other output formats (texinfo, nroff...). > Please let me know whether you find the search interface easier than the one > on the official site. I've got some problems with the existing search, myself, but on the first case I tried yours with there wasn't any advantage: "^methods" On 3/2/21, Richard Hainsworth wrote: > I've just passed a milestone in the development of a suite of modules > for rendering a collection of POD6 content files. > > Please take a look at http://raku.finanalyst.org and especially > http://raku.finanalyst.org/search.html > > Please let me know whether you find the search interface easier than the > one on the official site. > > (I will be updating based on feedback. Eg., I will be showing links and > visited links more clearly, but not with blue/purple of standard HTML) > > Both search functions (the official one, and mine) rely on the same > underlying information, but it is presented in a different way. I wanted > (a) more context when searching, (b) I want previous searches to be > retained in case the place I went to does not have the information was > looking for. > > Please also bear in mind that this is a system still being developed. So > there are some wrinkles: > > 1: There are numerous places in the official Raku docs where links > target 'virtual' files. These virtual files do not exist in the > Raku/docs directory, but are generated by the software developed to > render the POD6 files, namely Documentable. Personally, I think having > links to virtual files is fragile, and it does make the development of > an alternative system of viewing the docs more difficult. > > 2: The inheritance diagrams in the standard documentation system are not > cited in the official Raku docs, but are "sewn in" by Documentable based > on a single text file that describes relationships. > > The reasons I developed this new system? > > - I want to create a Blog site, a site for translations from English to > Welsh, and a site for my business that rely mostly on Raku, not php. > > - The underlying content of most CMS suites seems to be MarkDown. But > MarkDown does not allow for any meta data to be attached to text. POD6 > is both simple to write, but it also allows for meta data to be attached > to paragraphs, headers, blocks. You can see some of this potential by > clicking on the Collection button at raku.finanalyst.org > > - I'm not entirely happy with the Documentable/Pod::To::HTML modules > that are used to render Raku Documentation, and I hate it when people > criticise things without providing some systematic alternative. So > here's an alternative. > > I have more to say about Module documentation, but that involves another > topic. > >
A problem case for the site documentation search: the "^methods" method.
If you go to docs.raku.org and type "^methods" into the search window, you get a drop down looking something like this: class Method Submethod method methods Reference ^methods methods Submethods Routine method Site Search search entire site for ^methods There's a bunch of stuff in there I don't particularly want to see, but there's at least one entry that's definitely a hit: Reference ^methods That takes you to here: https://docs.raku.org/language/classtut#index-entry-$CIRCUMFLEX_ACCENTmethods On this, my browser leaves me at the top of the page, it doesn't jump to the internal label-- it's presumably missing from the page: and $CIRCUMFLEX_ACCENT is a variable that was supposed to interpolate but got treated as a literal. But anyway, I can do a text search for "^methods" now, and that takes me to this section, where there's some good material about "^methods": https://docs.raku.org/language/classtut#Introspection Every other entry in that drop down menu is a red herring. Particularly bad is the "search entire site" because it uses Google, and they don't treat characters like '^' as significant (once upon a time they had a "code search" feature, but it's long gone). There *are* other place whether "^methods" is mentioned in the documentation, but to find them I needed to do a git clone of the project and grep the source files on my hard drive: language/5to6-perlvar Language/operators Language/rb-nutshell Language/structures Type/ForeignCode Type/Metamodel/MethodContainer Type/Signature Type/Stash And actually, just the fact that the main search interface for the raku docs is a drop-down is a bit of an annoyance for me-- it no doubt seems very modern to some people, but I had to do a screen shot of it just to get it to sit still so I could type up the copy I included above.