mirror of git://git.qorg11.net/kill9.git
testing :D
This commit is contained in:
parent
2d9125d7da
commit
541a0dac1a
|
@ -12,7 +12,7 @@ promises, lazy evaluation, and grammars.
|
|||
|
||||
Sigils in Raku make sense unlike in Perl, for example:
|
||||
|
||||
~~~{.raku .numberLines}
|
||||
~~~{.perl .numberLines}
|
||||
# Perl:
|
||||
my %hash = (key1 => "value", key2 => "value2");
|
||||
$hash{key1} # value;
|
||||
|
@ -29,7 +29,7 @@ variables you declare are of the type "Any", which means that variable
|
|||
can have any time and can be converted to other type. Nevertheless you
|
||||
can specify which type you want the variable to be:
|
||||
|
||||
~~~{.raku .numberLines}
|
||||
~~~{.perl .numberLines}
|
||||
my Int $n = 3;
|
||||
my Str $s = "hello world";
|
||||
~~~
|
||||
|
@ -43,7 +43,7 @@ from `Mu`. All roads lead to Rome and all types lead to `Mu`.
|
|||
|
||||
Raku also has a decent Object Oriented interface:
|
||||
|
||||
~~~{.raku .numberLines}
|
||||
~~~{.perl .numberLines}
|
||||
Class Socket {
|
||||
has Int $.sockfd;
|
||||
|
||||
|
@ -63,12 +63,12 @@ $sock.send("hello from raku!");
|
|||
~~~
|
||||
|
||||
Calling C functions from Raku is stupidly easy, to do this only use
|
||||
the [NativeCall](https://docs.raku.org/language/nativecall) module
|
||||
the [NativeCall](https://docs.perl.org/language/nativecall) module
|
||||
which is included in the standard library, consider the following:
|
||||
|
||||
file.c:
|
||||
|
||||
~~~{.raku .numberLines}
|
||||
~~~{.perl .numberLines}
|
||||
#include <stdio.h>
|
||||
|
||||
int
|
||||
|
@ -83,9 +83,9 @@ You have to compile it so it's a shared library:
|
|||
|
||||
`gcc -fpic -shared file.c -o libfile.so`
|
||||
|
||||
file.raku:
|
||||
file.perl:
|
||||
|
||||
~~~{.raku .numberLines}
|
||||
~~~{.perl .numberLines}
|
||||
use NativeCall;
|
||||
|
||||
# Libpath, raku will add the lib and the .so automatically so you don't
|
||||
|
@ -117,7 +117,7 @@ really easily, but if you *really* want to call `fork()` you can call
|
|||
Async functions in raku are something very easy. The [language
|
||||
website](https://raku.org) give us this example:
|
||||
|
||||
~~~{.raku .numberLines}
|
||||
~~~{.perl .numberLines}
|
||||
start { sleep 1.5; print "hi" }
|
||||
await Supply.from-list(<A B C D E F>).throttle: 2, {
|
||||
sleep 0.5;
|
||||
|
@ -135,7 +135,7 @@ print the "hi" form the `start {}` block.
|
|||
|
||||
Raku also has promises:
|
||||
|
||||
~~~{.raku .numberLines}
|
||||
~~~{.perl .numberLines}
|
||||
|
||||
sub counter(Int $n) {
|
||||
for 0..$n -> $i {
|
||||
|
@ -170,17 +170,17 @@ compiles Raku code to be run in MoarVM or, if wanted, the JVM[^2].
|
|||
|
||||
## Resources
|
||||
|
||||
The [language documentation site](https://docs.raku.org) is pretty
|
||||
The [language documentation site](https://docs.perl.org) is pretty
|
||||
solid for reference. But if you want to learn the language from
|
||||
scratch you can use <https://raku.guide>. If you already know a
|
||||
programming language you can take the tour which shows you how to do
|
||||
things you already know in raku:
|
||||
|
||||
* [Perl to Raku](https://docs.raku.org/language/5to6-nutshell)
|
||||
* [JavaScript to Raku](https://docs.raku.org/language/js-nutshell)
|
||||
* [Haskell to Raku](https://docs.raku.org/language/haskell-to-p6)
|
||||
* [Python to Raku](https://docs.raku.org/language/py-nutshell)
|
||||
* [Ruby to Raku](https://docs.raku.org/language/rb-nutshell)
|
||||
* [Perl to Raku](https://docs.perl.org/language/5to6-nutshell)
|
||||
* [JavaScript to Raku](https://docs.perl.org/language/js-nutshell)
|
||||
* [Haskell to Raku](https://docs.perl.org/language/haskell-to-p6)
|
||||
* [Python to Raku](https://docs.perl.org/language/py-nutshell)
|
||||
* [Ruby to Raku](https://docs.perl.org/language/rb-nutshell)
|
||||
|
||||
There are channels in libera chat to discuss raku, #raku (general talk
|
||||
about the language), #raku-beginner (for beginner questions) and
|
||||
|
|
Loading…
Reference in New Issue