Re: RFC 181 (v1) Formats out of core / New format syntax
[email protected] ((Johan Vromans)) 31 Aug 2000 10:20:15 +0200
| Newsgroups | perl.perl6.language.io |
|---|---|
| Message-ID | <[email protected]> |
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