Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.

Allow inline data references #5

Open
schwern opened this issue Mar 17, 2014 · 2 comments
Open

Allow inline data references #5

schwern opened this issue Mar 17, 2014 · 2 comments

Comments

@schwern
Copy link
Contributor

schwern commented Mar 17, 2014

In Moose, if you want a data structure as a default you must use a code ref.

has list =>
    default => sub { [] };

This incurs an object construction penalty for calling that code ref. This is to ensure each object gets its own reference, not the same one over and over again. Because Mite is compiled, we may be able to get around this.

has list =>
    default => [];

Use Data::Dump::Streamer to dump reference defaults (except code refs) and add them to the constructor at compile time.

@schwern
Copy link
Contributor Author

schwern commented Mar 21, 2014

This can probably get away with just Data::Dumper, data references don't need lexical context, only code references.

Might need a scanner to ensure there's no code refs or filehandles in there.

@tobyink
Copy link

tobyink commented Aug 3, 2022

I've moved the Mite issue tracker here.

This is now implemented, but only for empty arrayrefs and empty hashrefs, which seem to be the most common use case.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants