Front page | perl.perl5.porters |
Postings from July 2021
From: Oodler 577 via perl5-porters
July 5, 2021 16:01
Message ID: 20210705160100.GB26930@odin.sdf-eu.org
This is my first attempt at birthing an RFC, so forgive me for not
doing this quite right.
I propose the introduction of an "unbless" functionality that simply
undoes what "bless" does.
Based on my research, there are 2 modules that do this:
* Data::Structure::Util (river pos. score of "2")
There is another, but this doesn't really count:
* Function::Fallback::CoreOrPP (wrapper around A::D, falls back to
Other than providing an inverse operation to "bless", there are
a couple of use cases that I can see this really providing some
1. eliminate, for most cases, the need to define a TO_JSON in
objects that one is wishing to serialize; idk about anyone reading
this but implementing this method always seem to just work around
the issue and rebuild the hashref based on the blessed reference
(i.e., I don't use any 'unbless' from CPAN)
2. somewhat related to #1, but it would greatly simplify "modern"
web framework request handling (e.g., Dancer2) by both encouraging
organized code reflective of RESTful API (object/verb friendly)
but make it easy to easily just send a hash reference for
serialization by the content fileter (e.g., JSON).
a. find an existing module for dual-use, and include it with core;
perhaps add this to Scalar::Util (seems like a good fit).
b. implement "unbless" internally
Looking forward to any thoughts on this one. If there is a positive
reaction to my pre-pre-RFC; I'm happy doing the research to look
for evidence of wide spread use of:
* TO_JSON implementations
* other serializations done by effective/manual "unblessing"
My suspicion is this is a common pain point; I know it is for me.
And if we had an 'unbless' that was easily at hand, I would be
using it a lot and writing much less code to do something I know
should be available in a default installation of Perl.
SDF-EU Public Access UNIX System - http://sdfeu.org
irc.perl.org #openmp #pdl #native