Perl6 RFC Librarian <[EMAIL PROTECTED]> writes:

> Formats out of core / New format syntax

Good work! This RFC opens the possibility to normalize (e.g. make the
syntax no longer something exceptional) the formats.

>    my format $FILE_FORMAT = q(
> @<<<<<<<<<<<<<:  @<<<<<<<<
> $name, $ssn
> );

Is there any reason left to maintain formats as something internally
special? We could use ordinary strings:

     my $file_format = q(
  @<<<<<<<<<<<<<:  @<<<<<<<<
  $name, $ssn
  );

> However, I don't particularly like extra steps, personally.

How about providing the format string as an additional argument to
write?

  write $fh, $format_string;

This makes it also easy to use several different formats on the same
file handle.

> =head1 IMPLEMENTATION

What about efficiency?
Perl could compile the format (much like it is done now) upon first
use, and cache the result. As long as the format string does not
change the cached result can be used.

Alternatively, if a real internal format type, proposed name: Format :-),
would be desirable, yet anoter quoting operator could be useful:

     my $file_format = qf(
  @<<<<<<<<<<<<<:  @<<<<<<<<
  $name, $ssn
  );

Now, $file_format would be a Format object (compare this with qr//,
that produces a Regex object).

> [2] We might consider making a special case in the Perl parser so that

This is exactly what we must try to avoid as much as possible. There
are too many special cases already.

With the above changes to the RFC, formats become nicely integrated
conforming language objects.

-- Johan

Reply via email to