parrot / parrot

Parrot Virtual Machine
http://parrot.org
Artistic License 2.0
593 stars 138 forks source link

Singleton PMCs are deprecated #663

Open Whiteknight opened 13 years ago

Whiteknight commented 13 years ago

Parrot shouldn't be responsible for implementing the singleton contract for PMCs. Our current implementation of it is very bad anyway.

If HLLs or other projects want singletons, they should be able to implement the behavior themselves.

Types such as Env and OS don't have state so don't need to be singletons. They are basically just collections of methods, and it's very cheap for us to just create multiple copies of them if needed.

The scheduler is a different story. It does have state, so we need to only have one of those in the system at a time. There are ways to prevent users from creating a scheduler from PIR code. The scheduler reference is available (or should be) by introspecting the current interp PMC.

Originally http://trac.parrot.org/parrot/ticket/2038

Whiteknight commented 12 years ago

I've created the whiteknight/gh_663 branch to work on this issue. In this branch I've removed much of the singleton logic from the two remaining singleton PMCs in the repo: Env and Null. In this branch Parrot builds but several tests fail in coretest. I haven't taken time to track down any of these failures yet.