🦋 Welcome to the MAIN() IRC channel of the Raku Programming Language (raku.org). This channel is logged for the purpose of keeping a history about its development | evalbot usage: 'm: say 3;' or /msg camelia m: ... | Log inspection is getting closer to beta. If you're a beginner, you can also check out the #raku-beginner channel!
Set by lizmat on 25 August 2021.
guifa Skarsnik: if you look in the Raku grammar, the normal way to do it is 00:12
token foo { <bar> || <.error> }
m: grammar Foo { token TOP { [<alpha> || <.error: 'need letter'>]+ }; method error ($msg) { die $msg }; }; say Foo.parse('ab3'); 00:16
camelia need letter
in method error at <tmp> line 1
in regex TOP at <tmp> line 1
in block <unit> at <tmp> line 1
guifa m: grammar Foo { token TOP { [<alpha> || <.error: 'need letter'>]+ }; method error ($msg) { die $msg }; }; say Foo.parse('abc');
camelia need letter
in method error at <tmp> line 1
in regex TOP at <tmp> line 1
in block <unit> at <tmp> line 1
guifa err
yeah, duh, it's bombing at end of string 00:20
but anyways, that's the idea
SmokeMachine I like doing error like this: github.com/FCO/bernalang/blob/572c...r.pm6#L186 01:54
Voldenet >A friend twitted his terrible idea of writing a programming language entirely without special characters. 03:26
it exists, it's called pascal
tonyo what does special characters mean in this instance? 03:57
Voldenet anything not being alnum or whitespace 04:31
Nemokosch Why Pascal? It has square brackets, semicolons and normal operators 09:35
lizmat clickbaits rakudoweekly.blog/2022/01/10/2022-...-perching/ 09:41
Nemokosch anyway, it reminds me of the weird habit of obsessing over banal syntax decisions in programming languages 09:45
the law of triviality
and "it looks like a real language, it has brackets after all" as a phenomenon
El_Che damn, Pascal was probably the first language I learnt (and forgot) 10:06
who's calling me old??
moritz_ I learned qbasic before flirting with Pascal 10:12
Nemokosch It was my first language as well so surely not me
😄
El_Che moritz_: I didn't have a pc, but look at the source of those gorilla games :) 10:13
Nemokosch a part of the story is that I learned Pascal as a first language in 2011 as a first encounter with programming 😛 10:14
El_Che 2011, wow 10:15
let me guess. you also have vinyl LPs :)
moritz_ El_Che: I implemented extra features and levels for "nibbles" (the snake-like game in qbasic)
El_Che oh, I remember it 10:16
stanrifkin Anyone also get an git protocol error with 'rakubrew available'? 10:17
Nemokosch I bought one LP but you know, where do I put the player and the speakers? Nowadays, buying CD's is just retro enough 10:18
El_Che true, very true
Nemokosch and don't write Free Pascal off 😼
El_Che I remember all the excitement in the Linux world about Lazarus (and the meh reaction when it finally arrived) en.wikipedia.org/wiki/Lazarus_(software) 10:19
stanrifkin why the "meh" reaction? 10:20
El_Che because it was very --very-- hyped
Nemokosch my question exactly
stanrifkin Lazarus is used in our school system here 10:21
El_Che and it was rather buggy
stanrifkin ah ok
El_Che it may be ok now
I am talking about 20 y agi
stanrifkin i heard this "tourist" guy uses free pascal occasionally in competitive programming. 10:22
Nemokosch I don't know, I haven't used Lazarus for some time
But I support the development of Castle Engine
I think we have to be thankful for the existence of one actively developed, multiplatform game engine for Object Pascal
lately with Delphi support as well, so I heard 🙂 10:23
El_Che Delphi was very popular 10:24
stanrifkin "The unauthenticated git protocol on port 9418 is no longer supported." with rakubrew available
i am not much into git stuff. Should I set GIT_PROTOCOL environment variable?
Nemokosch Also, I tend to pick Lazarus software out there
like PyScripter or Cudatext
I wonder what you are doing 10:26
stanrifkin GIT_PROTOCOL=https solved my problem. I looked into the rakubrew source code. It defaulted to "git". 10:53
Skarsnik this is weird 11:01
El_Che I would expect to default to https, idd 11:35
raise an issue?
stanrifkin i don't know how :) 11:40
i think rakubrew crew are reading this and it gets corrected soon 11:41
El_Che github.com/tadzik/rakudobrew/issues 11:42
github.com/tadzik/rakudobrew/issues/69
there is one
stanrifkin El_Che: ah yeah. already addressed 11:43
El_Che: in 2015? :) 11:44
El_Che I haven't used rakudobrew in a while, I don't know how active it is 11:46
stanrifkin El_Che: what do you use? I am used to perlbrew. So natural I use rakubrew. 11:47
El_Che I build Linux packages 11:47
Nemokosch I thought rakubrew was the way to go 11:55
github.com/Raku/App-Rakubrew 11:56
rakudobrew is an older version 11:57
the github page actually says that
Geth App-Rakubrew: a1e15f493c | (Patrick Böker)++ | 2 files
Switch Git protocol to https

This follows fact that GitHub disabled the `git` protocol.
12:53
App-Rakubrew: fb7d4c5297 | (Patrick Böker)++ | .circleci/config.yml
Update CircleCI MacOS base image

The previous one is to be removed.
App-Rakubrew: ccfd316ee1 | (Patrick Böker)++ | 4 files
Version 26
12:54
thowe I've been looking for a while for a good academic example or discussion about how one should go about building a CLI... Like a shell or really any command interpreter. Also think Juniper or Cisco switch CLI. Is there a "pattern" for that that I would be naive for not using? 16:38
I want all the fancy things like command auto completion etc... 16:39
Do I just build a loop and a data structure that has the commands in it and somehow knows how to dispatch to the right mehtod for them? That sounds like the naive solution but I dunno. 16:40
jercos that certainly sounds like a working start to me. I don't know of an absolute standard for interpreters or repls, and well... some existing shells would make pretty poor examples to copy the structure of :p 17:04
for most shells I know of, the first word being auto-completed is from a list of valid commands, while completion for a command's arguments are either generic (into the local filesystem) or entirely determined by the specific command. 17:08
using a naive initial structure doesn't rule out building on more complex functionality 17:10
thowe I guess. I just don't want to put something out there that's going to be frowned upon. 17:14
MasterDuke you could look at some existing ones. e.g., zef, mi6 17:15
thowe zef has a cli? 17:16
tonyo zef has a cli. 17:19
thowe how do you start it? it just seems to take commands and exit. 17:20
MasterDuke ah, you want an interactive cli, like the repl 17:21
thowe yeah... Otherwise I might look for something like Perl's App::Cmd
wish there was an App::Cmd for interactive shell framework. 17:22
psql CLI is a good example of what I want I guess, but not so many features needed. 17:23
thowe looks like Arne Sommer might have written one for some kind of transportation planning thing... I might look at that. 17:32
guifa for Raku, the nice thing is that you can run on a loop and have a grammar parse stuff, which can make dispatching much cleaner/straightforward 17:34
thowe guifa, OK, yeah... That sounds like something I want to do. I also feel like I need to capture every character entered, though. So I can do tab completion. and if not a special character, just somehow do nothing and let it sit on the command line. I'm a little fuzzy on how that would work. 17:37
solitario n/20 17:38
guifa yeah, that's something I'm not as sure how to do. It's super easy if you're okay waiting for the enter key ha
thowe Sommer's networkplanner command uses "Linenoise", which may do some of these things for you(?) 17:43
I really need to get it through my head what a "callback" is. 17:46
guifa Yeah, trick with linenoise is it's a binary dependency, rather than pure Raku. But given the complexities of doing anything other than "type command, hit enter, process command", it's understandable it's not exactly a built in in most languages 17:47
the niche for a nice CLI library would be one that provides for a fallback if linenoise isn't available for some reason 17:48
[Coke] wasn't someone already working on that? 17:57
japhb, maybe? 17:58
thowe I'm happy to test maybe. Hitting tab key in networkplanner crashes it. 18:01
what's japhb's cpan name? 18:03
thowe ah, this? raku.land/zef:japhb/Terminal::LineEditor 18:28
OK, japhb has some neat stuff. they can have all my stars. 18:35
guifa haha there are osme really nifty modules out there 18:42
tonyo there's also a readline module 19:05
either is worth using so you don't need to handle `up` key or emulate history 19:06
thowe a pure raku solution would be nifty, but I'm asking japhb about command completion and disambiguation of short forms... I don't see a way to do it from his README. 19:07
tonyo it's one of those simple seeming problems that gets out of control with features quickly 19:19
thowe yeah, that's why I'm looking for a bottled solution :) 19:29
stevied someone should nudge whoever is in charge of homebrew package to get it updated: formulae.brew.sh/formula/rakudo-star 19:55
the version I was using was badly broken when trying to load modules
I'm on monterey 19:57
El_Che use rakudo instead instead 19:58
(that's what I use when in macos)
stevied I'm using the binary 19:59
guifa I really need to figure out a way to do a DMG or .pkg install for Rakudo. Gatekeeper is annoying AF with command-line only stuff 20:00
stevied that would be nice. 20:03
what's gatekeeper? 20:05
perryprog macOS thingie that does security stuff with installing stuff 20:17
it's actually quite good but can be a huge pain when installing DMGs/.pkgs from unknown sources (which is common for devs)
(which I think is quite ironic
guifa perryprog it's not terrible as long as the whole package is signed. the problem is, a CLI thing isn't an application package 20:21
perryprog Right
guifa so from what I was reading, you basically create a dumy application of sorts, and it can sign its command line stuff
anyways, I'm sure once I figure it out it'll be easy to make releases just.... I need to stop adding new projects to my plate 20:22
perryprog guifa, I believe Julia actually does exactly what you're looking to do 20:24
I have a Julia.app that basically just starts julia in Terminal.app—I personally have never used it, but I'm going guess they're doing what you're describing there 20:26
stevied oh, right, you have to do that security thing
I have an apple developer account
maybe that would help
guifa I'd imagine to do "julia foo" on command line they'd need to adjust the path var. Not sure if the app itself can do that, or if it that would be handled by the installer. 20:27
perryprog guifa if you look at brew cat --cask julia you can see what exactly is being done 20:29
but it seems there's a symlink (probably from brew?) that goes from /usr/local/bin to the .app's julia executable 20:30
yeah, it's homebrew linking it
perryprog I don't know why I installed it through the cask and not the formula, but it works 🤷‍♂️ 20:31
stevied With Moose in Perl, you could do a "lazy" build of class attributes. Is there a similar mechanism with Raku? 22:49
looks like I need a module for that? raku.land/cpan:JSTOWE/Attribute::Lazy 22:51
Nemokosch I noticed something odd with cached, trynna golf it 23:39
m: ```multi factorial(0) { 1 } 23:44
multi factorial($n) is cached { $n*factorial($n-1) }
say factorial(7);
```
m: multi factorial(0) { 1 } multi factorial($n) is cached { $n*factorial($n-1) } say factorial(7); 23:45
okay... then _trust me bro_ remains
this works alright
(use experimental :cached;)
m: use experimental :cached; multi factorial(0) { 1 } multi factorial($n) is cached { $n*factorial($n-1) } say factorial(7); 23:46
anyway, if you add _is cached_ to the constant clause (factorial(0)), the factorial(7) call will fail
`Constraint type check failed in binding to parameter '<anon>'; expected 0 but got 7` 23:49