Damn but I'm a sucker for punishment. :)

On Sun, Oct 31, 2021 at 12:14 AM ToddAndMargo via perl6-users
<perl6-us...@perl.org> wrote:
>
> I think you misunderstand.

Fwiw I think you misunderstand.

If the penny doesn't begin to drop with this email I think
my head will explode. Or maybe my tail.

> The code I want to convert is code that I wrote.
> I want to migrate it to Perl 6 from Perl 5 because
> Perl 5 is 20 times more difficult for me to maintain.

You've already said that (countless times).

So convert it!

> I am getting tired of "what the h--- is this and what the h--- is that"
> when I have to go into my Perl 5 code.

You've already said that.

Then rewrite it in Raku!

> Perl 5's subroutine syntax is an abomination for starters

(You've already said that.)

So don't use it, use Raku's instead!

> I write in Top Down.

(Yep.)

So do that!

> And Perl 5's OOP is a nightmare for me to read

You've already said that countless times.

So write Raku OOP!

> which "Net::FTP" is very fond of.

NOT IF YOU USE IT IN RAKU!

How can you be missing this?

You `use` a package from Perl.

But you WRITE *ordinary* nice Raku code to use its features.

Here's another version of the example I provided a century ago:

my $ftp = Net::FTP.new: "some.host.name";

Can't you see that that's Raku code, not Perl code?

And just in case you're thinking that that's the Raku `Net::FTP`,
it isn't. It's the Perl one. Or maybe it *is* the Raku one. That's
the whole point. You can't tell.

It's only the `use` statement that precedes it that determines
which package you're using.

The subsequent Raku code that uses its features is written
in ordinary Raku code, without regard for whether the `use`d
package is a Perl one or a Raku one.

Raku magically translates between the two languages without
the Rakoon having to care that there's magic going on.

----

It's analogous to writing this:

say 42;

and running it on a Windows machine.

That USES Windows. But you don't have to READ the C source
code of Windows. (Indeed, you *can't* because it isn't open source.)

All you READ is YOUR code, which is `say 42;`, not C.

If you really can't see that this is Raku code:

my $ftp = Net::FTP.new: "some.host.name";

then my heads *and* tails will explode.

-----

But still, I get that you want eventually to stop *depending* on
Windows. (Or Perl packages, even if you pay them no heed.)

I got that from the start, *before* my first comment in this thread.

So hopefully you can understand that even if you were to *start*
`use`ing Perl packages in your Raku code, I'm *not* saying you
would need to *end up* with them.

That is to say, *starting* to `use` Perl packages in your Raku code
can be the best way to *stop* `use`ing them in your Raku code.

You start by `use`ing a Perl module. You write Raku code that
uses the module's features. When it's correctly doing what you
want, you then write a Raku module that replaces the Perl one.

This can happen in a matter of hours. Or can be done bit by bit,
over a longer period, using *both* modules, side-by-side, with
some code using features of the Perl module, other code using
features of the Raku module, and even passing data from one
to the other.

As part of this migration you might have:

use Net::FTP:from<Perl5>;
use Todd's::Raku::FTP;

my $ftp1 = Net::FTP.new: 'foo';
my $ftp2 = Todd's::Raku::FTP.new: 'bar';

...

sub connect-ftps ($ftpa, $ftpb) { ... }
connect-ftps $ftp1, $ftp2;

----

> And if the ftp module in Perl 6 is not ready yet

Why are you saying that?

The `Net::FTP` which is *written* in Perl can be *used* in Raku.
It's ready.

The `Net::FTP` which is *written* in Raku can be *used* in Raku.
It's ready.

> All I need is how to open and close a network connection.

All you need to do is to `use` a package with ONE LINE OF RAKU
CODE and then use the features of that package by writing some
more simple lines of Raku code.

Why reinvent wheels that are circular by writing half a spoke that's
already available in the wheels being made available to you for free?

> I have to use free hand ftp code where I write the command
> and run string already a few times in my Perl 5 code.

Just translate your Perl code to the equivalent Raku syntax.

Just a mechanical translation. For example, `->` in Perl becomes
`.` in Raku.

Then, at the top, append `:from<Perl5>` to the `use` statement for
`Net::FTP`.

Done.

--
love, raiph

Reply via email to