This channel is intended for people just starting with the Raku Programming Language (raku.org). Logs are available at irclogs.raku.org/raku-beginner/live.html Set by lizmat on 8 June 2022. |
|||
02:23
thowe left
02:24
thowe joined,
thowe left
02:29
thowe joined
|
|||
aris | How do I clear the REPL? | 02:32 | |
06:26
saint- left
|
|||
Nemokosch | I generally just make a call to shell | 06:44 | |
qx{clear} | |||
I guess on windows it would be cls instead of clear? | |||
deadmarshal | right on windows it's "cls" | 07:15 | |
08:27
jaguart joined
|
|||
jaguart | lizmat++ thanks :) | 08:28 | |
A question on old habits - and Raku optimisation - do Raku folks always use '' when there is no interpolation, or do ya'all just "" and leave it to the optimiser? | 08:41 | ||
I kind of hate pod6 :( - I write lots of comments, and use them to help me visually navigate my code. Trying to do this using pod6 does my head in | 09:04 | ||
Basic things, like #| on successive lines should just be one declarator block for the following code... | 09:06 | ||
aris | I'm on Windows. `qx{cls}` doesn't clear it. It just re-prompts. I'm using Powershell with Windows Terminal. | 09:09 | |
Nemokosch | well, then whatever it is called in powershell, lol | ||
aris | It is `cls` in Powershell but it has no effect in the REPL. | 09:11 | |
Nemokosch | not sure why anyone would use Raku on Windows tbh | ||
aris | because I use Windows | ||
Nemokosch | WSL | ||
aris | no thanks | ||
Nemokosch | ĀÆ\_(ć)_/ĀÆ | ||
aris | well the REPL should not prefer one OS over another | ||
Nemokosch | a developer should, however | 09:13 | |
aris | but I'm not | ||
Nemokosch | then again, not sure why want to clear the REPL, lol | ||
aris | it's messy | ||
Nemokosch | or why you are using terminal (let alone on Windows) in the first place | ||
aris | after a bunch of experimental statements | ||
why are you questioning what I'm using? | |||
Nemokosch | because it's not suited for what you want to do | ||
aris | am I committing a sin? | ||
Nemokosch | is it not obvious | ||
aris | jeez | ||
you must be a very proud guy | 09:14 | ||
Nemokosch | thanks for the assumptions I guess | 09:15 | |
aris | thanks for blaming random guy's choice of OS | ||
almighty person | |||
Nemokosch | you may call it blaming, I just said it's not suited for the goddamn thing you want to do | ||
aris | yeah so Raku isn't suitable on Windows you've said that like 3 times already at least | ||
Nemokosch | it would be more beneficial to evaluate whether this is true or not | ||
jaguart | aris - are you trying to reset your REPL session or clear the screen? | ||
aris | amazing of you to say that | ||
that's right | |||
Nemokosch | pretty sure this was an either-or question | ||
aris | I'd like to clear the REPL screen <@853712446660673566> | 09:17 | |
jaguart | I dont have your setup to test - does qx{dir} etc work? | 09:20 | |
aris | let me try | 09:21 | |
it works | |||
but not qx{cls} | |||
jaguart | try qx{clear} | ||
aris | error | ||
because it's not a powershell command | 09:22 | ||
jaguart | hmmm - clear works in my PowerShell | ||
Nemokosch | Look, I might have found something but again, cannot promise that it works in a terminal running powershell... | 09:23 | |
have you installed Linenoise of all REPL modules? | |||
aris | I'm on 5.1 not powershell core btw | 09:24 | |
jaguart | $PSVersionTable -> mine shows PSVersion 5.1 | ||
and both cls and clear are aliases to Clear-Host | |||
qx{Clear-Host} maybe? | 09:25 | ||
Nahita | <@426689195076091905> i use `run "clear" andthen "".say` | ||
aris | yeah clear works actually on my powershell 5.1 but qx{clear} throws an error | ||
Nemokosch | in Linenoise, supposedly ctrl+L would clear the screen | ||
aris | ```'clear' is not recognized as an internal or external command, | ||
operable program or batch file.``` | |||
let me c | |||
error | |||
```'Clear-Host' is not recognized as an internal or external command, | |||
operable program or batch file.``` | |||
jaguart | Do they work in just PowerShell outside the REPL? | 09:26 | |
aris | no biggie I'll just experiment by running a script | 09:27 | |
clear works outside REPL | |||
Clear-Host works too | |||
outside REPL | |||
Nahita | i wrapped this in a function in a module | 09:29 | |
``` | |||
sub was is export { | |||
run "clear" andthen return ""; | |||
``` | |||
inspired from this: perlgeek.de/blog-en/perl-6/2013-repl-trick.html | |||
i wrapped this in a function in a module | |||
``` | |||
sub was is export { | |||
run "clear" andthen return ""; | |||
} | |||
``` | |||
inspired from this: perlgeek.de/blog-en/perl-6/2013-repl-trick.html | |||
the i write `was` to clear | |||
but not sure why it doesn't work for you :\ | |||
aris | ```Welcome to Rakudo(tm) v2022.06. | ||
Implementing the Raku(R) Programming Language v6.d. | |||
Built on MoarVM version 2022.06. | |||
To exit type 'exit' or '^Z' | |||
[0] > sub was is export { | |||
* run "clear" andthen return ""; | |||
* } | |||
&was | |||
[1] > was | |||
[2] > was() | |||
09:29
discord-raku-bot left
09:30
discord-raku-bot joined
|
|||
jaguart | I assume that `run 'clear';` doesn't work any better than `qx{clear}?` | 09:33 | |
09:34
discord-raku-bot left,
discord-raku-bot joined
|
|||
jaguart | and `shell( 'clear' )` | 09:36 | |
Nahita | np; interesting... | ||
side question: does invocation of `raku` to open the REPL starts using a lot of CPU for you as well? I witness this in a long-standing program as well (e.g., a GTK3 application). It uses ~16% CPU when even Chrome uses no more than 2% :p | |||
it wouldn't matter for me but the computer starts making sounds, so i notice :p | |||
np; interesting... | |||
side question: does invocation of `raku` to open the REPL starts using a lot of CPU for you as well? I witness this in a long-standing program as well (e.g., a GTK3 application). It uses ~16% CPU when even Chrome uses no more than 2% :p (on Windows) | |||
jaguart | aris: see docs.raku.org/language/independent...#sub_shell | ||
Nahita | then i write `was` to clear | 09:37 | |
jaguart | which indicated that on windows the system shell defaults to %*ENV<ComSpec> | ||
so if you `say %*ENV<ComSpec>` you should see which shell the REPL is running - might not be powershell? | |||
hmm - `run` doesnt use the shell... | 09:38 | ||
Heres the powershell tty clear sequence: echo "$([char]27)c" | 09:46 | ||
so you might just be able to say this to clear the screen | |||
bbl | 09:47 | ||
aris | yeah it's running cmd (DOS) even though I executed the REPL from Powershell | 09:52 | |
weird | |||
that's why the error messages said "batch file" in them | 09:57 | ||
Nemokosch | once again: can you install the Linenoise module? | 10:05 | |
aris | yeah my cpu usage jumps by 5% when I execute REPL in Powershell | 11:30 | |
4 of my CPU cores are constantly active while REPL is running | |||
lizmat | 4 ?? | 11:39 | |
aris | yup | 11:40 | |
when I exit they all die down | |||
11:42
discord-raku-bot left
11:43
discord-raku-bot joined
|
|||
to be more precise, 4 logical cores | 11:44 | ||
11:48
discord-raku-bot left,
discord-raku-bot joined
|
|||
SmokeMachine | aris: about clear, have you tried something like `print ā\o33[1H\o33[1Jā`? | 11:49 | |
Quibono | Does raku have TCO? | 11:50 | |
aris | I just tried printing that escape sequence and I got `Unable to initialize device PRN`. | 11:53 | |
I found `qx{powershell cls}` works but itās obviously overkill | 11:54 | ||
I found `qx{powershell cls}` works but itās obviously overkilled | |||
Nahita | oh, thanks. so there's something going on for Raku on Windows... | 11:55 | |
11:56
jaguart left
11:58
discord-raku-bot left,
discord-raku-bot joined
|
|||
aris | ``` | 11:58 | |
Welcome to Rakudo(tm) v2022.06. | 11:59 | ||
Implementing the Raku(R) Programming Language v6.d. | |||
Built on MoarVM version 2022.06. | |||
To exit type 'exit' or '^Z' | |||
[0] > qx{print "\o33[1H\o33[1J"} | |||
Unable to initialize device PRN | |||
[1] > | |||
``` | |||
Nemokosch | Somehow everybody seems to miss the fact that Linenoise apparently supports clearing the console by the Ctrl+L combination | 12:01 | |
Does it work on Windows? I have no idea but it's not obvious why it wouldn't, at least | |||
aris | `print "\033[1H\033[1J"` also gives me the same error message | 12:09 | |
I've also tried that in `cmd` (i.e. outside REPL) | 12:10 | ||
Anyway, thanks a lot "raku-bots" for the help | 12:11 | ||
Anton Antonov | Of course, Machine Learning (ML) is "a lot about" real-time performance. š That is why so many companies are trying to hardwarize as much as they can of ML algorithms. | 14:22 | |
14:59
equinox joined
|
|||
Nahita | `.say for flat ($(24, 7),)` prints `(24, 7)`; however, `.say for flat $(24, 7)` prints 24, newline, 7; why is it flattening in this latter case? | 15:15 | |
Anton Antonov | Because of the additional containerization in `($(24, 7),)`. This has been discussed in StackExchange -- let me find the link... | 15:20 | |
Nahita | yes; despite that containerization, it flattens... | 15:21 | |
in the latter case, i mean | |||
Anton Antonov | See : stackoverflow.com/questions/416481...s-of-lists | ||
Nahita | isn't there that containerization, too? | ||
isn't there containerization, too? | |||
Anton Antonov | My rationale is that `$(24 ,7)` is thing that `flat` detects to be a list and makes it a `Seq` object; `($(24, 7), )` is a list of things, and `flat` makes a `Seq` object of that list. | 15:23 | |
I am not sure if summary / rational that helps -- if its is a summary it all... | 15:24 | ||
I am not sure if that summary / rationale helps -- if its is a summary it all... | 15:30 | ||
Nahita | i see, thanks... | 15:32 | |
i found this design.raku.org/S07.html#Iterable | 15:33 | ||
> Note that flat respects Scalar containers, and so: | |||
> | 15:34 | ||
> for flat $(1, 2) { } | |||
> | |||
> Will only do one iteration. | |||
but it does 2 iterations, and that's my confusion. | |||
Nemokosch | I think the docs are outdated on this one, and the described behavior doesn't sound too reasonable, either | 15:48 | |
Anton Antonov | My rationale is that `$(24 ,7)` is a thing that `flat` detects to be a list and makes it a `Seq` object; `($(24, 7), )` is a list of things, and `flat` makes a `Seq` object of that list. | 15:50 | |
Nahita | docs still say containerization is respected | 15:57 | |
Nemokosch | I don't read it that way | 15:59 | |
Anton Antonov | I am not sure if that summary / rationale helps -- if its is a summary at all... | 16:00 | |
Nemokosch | "Interprets the invocant as a list (...)" now, what is $(1, 2) as a list? | ||
Also, multi flat(Iterable \a) | 16:01 | ||
It drops the container right away | |||
I wouldn't feel safe without trying this... | 16:07 | ||
m: dd $(1, 2).list | |||
Well, there you go | |||
16:07
ab5tract joined
|
|||
Nahita | does it though | 16:09 | |
```py | |||
>>> sub f(Iterable \a) { say a.raku } | |||
&f | |||
>>> f $(24, 7) | |||
$(24, 7) | |||
``` | |||
Nemokosch | Well, sigilless variables do not have containers | 16:13 | |
At the same time, the docs also say that sigilless parameters always bind | |||
See, that's why I said that I wouldn't feel safe without checking the .list method š | 16:15 | ||
It won't matter | |||
16:16
guifa left
|
|||
gfldex | Sigilless symbols don't have containers created automatically. They can very well be bound to one. | 16:18 | |
Anton Antonov | How can check or verify that a sub is defined? With `&some-func.defined` I get `True` if `some-func` is defined, but otherwise I get the error message "Undeclared routine:...". | 16:31 | |
Nemokosch | find-method? | 16:36 | |
^find_method, that is... | |||
Kaiepi | `\o33[1H\o33[1J` doesn't look right... | ||
or rather it's overcomplicating things | |||
gfldex | <@694526400488669234> you have to do a runtime resolution for the symbol, match against Routine. Routine will always return True on .define, so that is redundant. | 16:38 | |
Kaiepi | powershell has *some* capacity for ansi, just i need to rebuild to test | 16:40 | |
Nemokosch | Maybe dynamic linking can be troublesome though | ||
16:41
jaguart joined
|
|||
ab5tract | Regarding the runtime resolution of the symbol, you would look into the current package scope to check whether the name is defined and whether it is a Routine | 16:43 | |
That said, it sounds a bit like an X-Y problem.. unless you are doing some fairly nasty evals, you should be able to know whether a sub is in scope or not | 16:45 | ||
Kaiepi | in the meantine, have some chad newlines | 16:48 | |
in the meantime, have some chad newlines | 16:49 | ||
gfldex | m:my &lol-func = Routine; | 16:54 | |
Nemokosch | What is VPR? A Viper? š± | 16:55 | |
17:01
equinox left
|
|||
Kaiepi | it's `LINE POSITION FORWARD` as per ecma-48 | 17:13 | |
no idea why that's the acronym | |||
long `NL` | |||
(in its default format) | |||
i have no idea how i was building moarvm before because i don't have `cl` or `clang` apparently | 17:20 | ||
17:27
Kaiepi left
|
|||
ofc it needs a reboot to do anything... | 17:27 | ||
17:49
jaguart left
17:57
jaguart joined
17:58
jaguart left,
jaguart joined
18:37
guifa joined
|
|||
at last, moar with msvc | 18:40 | ||
complete pita to get the environment set up | |||
`INCLUDE`/`LIB`/`PATH` scavenger hunt. weeee š | |||
š | 18:48 | ||
try `\e[H\[J` | |||
try `\e[H\e[J` | 18:49 | ||
works in `mcd` too | 18:52 | ||
works in `ccd` too | |||
works in `cmd` too | |||
Nahita | (fwiw, it moves the cursor to top, but leaves every text in place, i.e., doesn't clear.) | 18:54 | |
(fwiw, it moves the cursor to top, but leaves every text in place, i.e., doesn't clear for me.) | 18:55 | ||
but i hope it works for \<@426689195076091905> | 18:56 | ||
that's the Raku syntax of mentioning a Discord user :p | |||
(i tried to escape @, and that happened.) | |||
18:58
Kaiepi joined
|
|||
Kaiepi | <@836605577400549436> `\e[H\e[2J`? | 19:00 | |
Nahita | that works! | 19:01 | |
Kaiepi | bingo | ||
Nahita | in case you are still on Windows, can you please tell if opening the raku REPL, for example, immediately causes an increase in the CPU usage? Like 5 to 15 percent | 19:13 | |
Kaiepi | in a minute | ||
it's around 5% on a new-ish workstation | 19:19 | ||
(the big spikes are launching the process manager and me screencapping) | |||
(the big spikes are me launching the process manager and screencapping) | |||
Nahita | thanks a lot | ||
Kaiepi | np | 19:21 | |
20:28
ab5tract left
|
|||
aris | I still get the same error with `print "\e[H\e[J"` in cmd: `Unable to initialize device PRN`. I don't know DOS syntax. So, maybe I didn't print it right. | 21:32 | |
Kaiepi | huh | 21:33 | |
aris | in fact the `print` command doesn't work no matter what input I give to it | 21:35 | |
it gives me the same error | |||
Kaiepi | weird | 21:39 | |
aris | I finally figured it out. In cmd, to insert the escape character, press `Ctrl+[`. So, to clear the REPL, run `qx{^[[H^[[J}`, where each `^[` represents the escape character entered by pressing `Ctrl+[`. | 22:05 | |
Thanks <@210313526928080896> for the help. | 22:06 | ||
I finally figured it out. In cmd, to insert the escape character, press `Ctrl+[`. So, to clear the REPL, run `qx{echo ^[[H^[[J}`, where each `^[` represents the escape character entered by pressing `Ctrl+[`. | |||
I finally figured it out. In Powershell and cmd, to insert the escape character, press `Ctrl+[`. So, to clear the REPL, run `qx{echo ^[[H^[[J}`, where each `^[` represents the escape character entered by pressing `Ctrl+[`. | 22:17 | ||
It's still a mystery though why the escape sequence works but `qx{cls}` doesn't. | 22:21 | ||
`say ^[[H^[[J` works too... (again, `^[` aren't literal characters but they represent the escape character entered with `Ctrl` + `[`) | |||
I finally figured it out. In Powershell and cmd, to insert the escape character, press `Ctrl` + `[`. So, to clear the REPL, run `qx{echo ^[[H^[[J}`, where each `^[` represents the escape character entered by pressing `Ctrl` + `[`. | 22:25 | ||
`say "\e[H\e[J"` works too | 22:32 | ||
which is much better than pressing `Ctrl` + `[` | 22:33 |