Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Meditating on raku-in-batch hybrids

by siberia-man (Friar)
on Feb 28, 2023 at 01:25 UTC ( [id://11150647]=perlmeditation: print w/replies, xml ) Need Help??

I am keen of collecting the computing polyglots. Honestly, they are bilingual - the main script with the small portion of the windows batch script as the second supporting language. And I like to call them hybrids.

I do it just for fun. And I know that some languages are hybridizing very well. Some of them are resistant to hybridization. And some of them that can be hybridized result to awful stuff. Such kind of polyglots I call chimeras.

Couple days ago I began thinking about how to embed a raku script within a batch file in the same way how it was done for perl with pl2bat.bat. I am not so familiar with raku and my first attempt doesn't look quite elegant. But it's working version and seems following the raku syntax and strictness.

I kindly ask fellows to help to improve it and make it better if it's possible.
@rem = q:to/use strict;/; @echo off raku -e "('no strict;' ~ (slurp q<%~f0>)).EVAL" %* goto :EOF use strict; say "Hello! I am Raku."; say @*ARGS;
Below are more suggestions from another people. The main problem with their versions that they are not pure hybrids and I classify them standing closer to chimeras because they use the raku syntax that is considered as the non existent external command and throws warnings by default. And it's a bit risky because it has non-zero probability to have such commands and execute them.

Both use the strange construction @@. What does it mean? I tried to google the answer but with no any success. In terms of the raku syntax I guess it looks like a nameless array of array. But I am not 100% sure.

The version using heredoc
@@; $_ = q:to/@@; goto :EOF/; # 2>nul @@; raku "%~f0" %* @@; goto :EOF say "Hello! I am Raku."; say @*ARGS;
The version using a multiline comments
@@; #`{ 2>nul @echo off raku "%~f0" %* goto :EOF } say "Hello! I am Raku."; say @*ARGS;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://11150647]
Front-paged by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (4)
As of 2024-03-28 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found