in reply to Packing unsafe string for later context-based escaping

I don't think I have ever seen something like that in a module, but I like it. This post would have been at its place in CUFP, because strings that automatically escape themselves in the right way depending on the context (scope, in this case) is one cool feature IMHO. And I don't think the languages perl is often compared with (ruby and python) provide such an easy and transparent way of achieving an equivalent result, if at all. Which makes it a perl specific feature, and not a Cool Use For Most High Level Languages.

++ to you

  • Comment on Re: Packing unsafe string for later context-based escaping

Replies are listed 'Best First'.
Re^2: Packing unsafe string for later context-based escaping
by Dallaylaen (Chaplain) on Jan 05, 2016 at 18:12 UTC

    Thanks for your reply!

    I believe I could write it in Python as well. The __str__ method would handle stringification (concrete method selection in our case). Scoping can be implemented in any language that has destructors (__del__ in Python's case) by using guard variables. Ditto C++ (via operator const string & IIRC).

    UPDATE I was totally wrong about Python's scoping, looks like it's done another way.

    Not sure how it can be done in Java and Javascript, though.

    And... I'm a bit ashamed to ask, but... What is CUFP?

      No need to be, I didn't use the full name. It's Cool Uses for Perl where people talk about cool things that perl allows you to do, though sometimes it relies on features shared among high level languages, which explains my post.

      Indeed there are ways to obtain the same result with objects and destructors, pretty nice solution as well actually.

        Ouch. Now I'm twice as ashamed for googling instead of scrolling the freaking page up! :))))))
Re^2: Packing unsafe string for later context-based escaping
by Dallaylaen (Chaplain) on Jan 05, 2016 at 20:03 UTC