Is it possible to implement lisp & ldquo; language & rdquo; in Perl 6?


In here, interpretation of Hello $world per each quoting symbol I mean language.

 $world = "WΩrlδ"
"(Hell)*o $world\n"           # <--- plain (Hell)*o, resolve $world, escape \n
'(Hell)*o $world\n'           # <--- plain (Hell)*o, plain $world, escape \n
/(Hell)*o $world\n/           # <--- regexp (Hell)*, resolve $world, interpret \n
<(Hell)*o $world\n>           # <--- make list ["(Hello*o", "$world\n"]
{(Hell)*o $world\n}           # <--- syntax error, this language cant' parse it

So is Perl 6 powerful enough to be able to exist in future language for something like

my $emacs_func = (defun perl-backward-to-start-of-continued-exp (lim)
      (if (= (preceding-char) ?\))
          (forward-sexp -1))
      (if (<= (point) lim)
          (goto-char (1+ lim)))
      (skip-chars-forward " \t\f"))

$  typeof($emacs_func)
> Emacs Lisp list

So, question obviously is: can it be done in present specification (or even implementation) of Perl 6?

Perl 6's grammar is just a grammar written in Perl 6, and very malleable (though current implementations don't quite provide all of the specced flexibility).

So what you ask is possible in principle, but might need more care. In particular are round parenthesis perfectly valid Perl 6 syntax, and even (defun a b) parses as valid Perl 6. So you'd need to be /really/ careful with disambiguation rules, and it would be a huge can of worms.

It probably makes more sense to restrict Lisp syntax to some specially delimited syntactic construct (like lisp(...) or q:lisp{...}), though some amount of mixing would probably be implementable.

I'm sure that once such features are available in a compiler, we'll see a whole lot of interesting experiments, and only those experiments will show what kind of language mixing is both feasible and useful.