Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

new libraries

7 views
Skip to first unread message

Jens Rieks

unread,
Apr 8, 2004, 2:28:49 PM4/8/04
to perl6-i...@perl.org
Hi,

I've committed Data::Sort, Data::Replace and Data::Escape.

Data::Sort is a new version of the old library/sort.imc. The old file is still
there, but will be removed soon.

Data::Replace replaces every occurrence of one PMC in a nested data structure
with another PMC.

Data::Escape contains a function "String" that escapes the string.

The libraries are used by Data::Dumper and are also required for the EBNF
parser.

jens

Tim Bunce

unread,
Apr 8, 2004, 5:49:36 PM4/8/04
to Jens Rieks, perl6-i...@perl.org
On Thu, Apr 08, 2004 at 08:28:49PM +0200, Jens Rieks wrote:
>
> Data::Replace replaces every occurrence of one PMC in a nested data structure
> with another PMC.

I'm not sure what that means, but Data::Replace seems too vague.
What is it?

> Data::Escape contains a function "String" that escapes the string.

Wouldn't escape_string be better?

(And I wonder how different languages escape strings,
and if there's a common subset that'll work for all/most of them.)

Tim [wearing a tired old namespace police hat]

Will Coleda

unread,
Apr 8, 2004, 7:56:36 PM4/8/04
to Tim Bunce, Jens Rieks, perl6-i...@perl.org
I'm pretty sure this is escaping from PIR's point of view - it started
life as a method for _dumper() to dump strings that you could then copy
back into PIR and have them work. (though it looks like Jens has made
it far more functional since then.)

Presumably individual languages will have their own routines - I would
expect anything in library that isn't in a language-specific directory
to be PIR/PASM specific.

I agree about the namespace issues though. definitely something to keep
an eye on.

Wasn't there talk about Class names in parrot being prefixed by their
language? (in which case we've each got our own namespace to pollute)

--
Will "Coke" Coleda will at coleda
dot com

Jens Rieks

unread,
Apr 9, 2004, 9:02:00 AM4/9/04
to perl6-i...@perl.org, Tim Bunce
Hi,

On Thursday 08 April 2004 23:49, Tim Bunce wrote:
> On Thu, Apr 08, 2004 at 08:28:49PM +0200, Jens Rieks wrote:
> > Data::Replace replaces every occurrence of one PMC in a nested data
> > structure with another PMC.
>
> I'm not sure what that means, but Data::Replace seems too vague.
> What is it?

if you have a data structure [A, B, [C, D, E], C, D, E], where each letter
represents a PMC. With Data::Replace, you can for example replace each D PMC
with another PMC value.
Do you have a better name for it?

> > Data::Escape contains a function "String" that escapes the string.
>
> Wouldn't escape_string be better?

What would be redundant, the namespace already contains "Escape".

> (And I wonder how different languages escape strings,
> and if there's a common subset that'll work for all/most of them.)

Its C and PIR like escaping, it relaces some ASCII code with \n, \t, \r and
replaces ' with \' in strings quoted with ', and " with \" in strings quoted
with ".

> Tim [wearing a tired old namespace police hat]

:-)

jens

Gregor N. Purdy

unread,
Apr 9, 2004, 10:09:42 AM4/9/04
to Jens Rieks, perl6-i...@perl.org, Tim Bunce
Sounds like a deep version of map...


Regards,

-- Gregor

--
Gregor Purdy gre...@focusresearch.com
Focus Research, Inc. http://www.focusresearch.com/

Tim Bunce

unread,
Apr 10, 2004, 6:42:05 AM4/10/04
to Jens Rieks, perl6-i...@perl.org, Tim Bunce
On Fri, Apr 09, 2004 at 03:02:00PM +0200, Jens Rieks wrote:
> Hi,
>
> On Thursday 08 April 2004 23:49, Tim Bunce wrote:
> > On Thu, Apr 08, 2004 at 08:28:49PM +0200, Jens Rieks wrote:
> > > Data::Replace replaces every occurrence of one PMC in a nested data
> > > structure with another PMC.
> >
> > I'm not sure what that means, but Data::Replace seems too vague.
> > What is it?
>
> if you have a data structure [A, B, [C, D, E], C, D, E], where each letter
> represents a PMC. With Data::Replace, you can for example replace each D PMC
> with another PMC value.
> Do you have a better name for it?

Perhaps Data::DeepReplacePMC

(We've learnt the hard way with Perl5 modules names that more words are good.
Keeping module names very short is a false economy.)

> > > Data::Escape contains a function "String" that escapes the string.
> >
> > Wouldn't escape_string be better?
>
> What would be redundant, the namespace already contains "Escape".

You're assuming that the name will always be seen in the context
of it defining module. That may not be the case in the future.

> > (And I wonder how different languages escape strings,
> > and if there's a common subset that'll work for all/most of them.)
>
> Its C and PIR like escaping, it relaces some ASCII code with \n, \t, \r and
> replaces ' with \' in strings quoted with ', and " with \" in strings quoted
> with ".

escape_string_cstyle perhaps

Tim.

Jarkko Hietaniemi

unread,
Apr 10, 2004, 6:49:37 AM4/10/04
to perl6-i...@perl.org, Tim Bunce, Jens Rieks, perl6-i...@perl.org
>
> (We've learnt the hard way with Perl5 modules names that more words are good.

And more words that mean something... "Data" ranks right up there as the
worst possible names for anything.

Tim Bunce

unread,
Apr 13, 2004, 9:11:07 PM4/13/04
to Jarkko Hietaniemi, perl6-i...@perl.org, Tim Bunce, Jens Rieks
On Sat, Apr 10, 2004 at 01:49:37PM +0300, Jarkko Hietaniemi wrote:
> >
> > (We've learnt the hard way with Perl5 modules names that more words are good.
>
> And more words that mean something... "Data" ranks right up there as the
> worst possible names for anything.

(Nah, "Sys" and "System" are at the top of the list :)

Anyone wanting to act as a guiding light for Perl6 module naming is
very welcome. I've been there and done that once. For ten years.
My time is up.

Tim.

Jens Rieks

unread,
Apr 14, 2004, 6:28:33 AM4/14/04
to Tim Bunce, perl6-i...@perl.org
On Saturday 10 April 2004 12:42, Tim Bunce wrote:
> Perhaps Data::DeepReplacePMC
What do you think about:

PMC::DeepReplace (Data::Replace)
PMC::Printable (Data::Escape)
PMC::Sort (Data::Sort)
PMC::Dumper (Data::Dumper)

> (We've learnt the hard way with Perl5 modules names that more words are
> good. Keeping module names very short is a false economy.)

If the name isn't good enough, it is not always the best idea to make it just
longer.

> You're assuming that the name will always be seen in the context
> of it defining module. That may not be the case in the future.

"Other language" has to use find_global in order to find the Subs declared in
these libraries. You have to specify the namespace as well as the function
name to lookup the sub ref. The language itself can then store it in a
variable named "escape_string" or something similar.


> > > (And I wonder how different languages escape strings,
> > > and if there's a common subset that'll work for all/most of them.)
> >
> > Its C and PIR like escaping, it relaces some ASCII code with \n, \t, \r
> > and replaces ' with \' in strings quoted with ', and " with \" in strings
> > quoted with ".
>
> escape_string_cstyle perhaps

It is a widely used format.
escape_string_c_and_cpp_and_perl_and_shell_and_so_on_style? ;-)

> Tim.
jens

Jarkko Hietaniemi

unread,
Apr 14, 2004, 5:49:50 AM4/14/04
to perl6-i...@perl.org, Tim Bunce, perl6-i...@perl.org, Jens Rieks
Tim Bunce wrote:

> On Sat, Apr 10, 2004 at 01:49:37PM +0300, Jarkko Hietaniemi wrote:
>
>>>(We've learnt the hard way with Perl5 modules names that more words are good.
>>
>>And more words that mean something... "Data" ranks right up there as the
>>worst possible names for anything.
>
>
> (Nah, "Sys" and "System" are at the top of the list :)

Sys::Data::System, anyone? (Or *cough* Meta *cough*)

> Anyone wanting to act as a guiding light for Perl6 module naming is
> very welcome. I've been there and done that once. For ten years.
> My time is up.

Amen.

0 new messages