Git Product home page Git Product logo

Comments (5)

ap avatar ap commented on July 22, 2024

[You can edit your own posts on GitHub, btw. I’ve applied your correction for you.]

from bencode.

ap avatar ap commented on July 22, 2024

I am aware that the original format doesn't cover undefined values, so you probably don't want to support round-tripping of undef.

Well… can’t. 😊

I would suggest either croaking or encoding a zero-length string in place of the undef (configurable by an option?) to be better than invalid output.

You don’t even need to suggest that, it’s just a statement of fact. And your stated alternatives are the obvious ways of dealing with undefs.

Of those two options, since the module is already documented to croak on unhandled data types, croaking for undefs would be the lazier choice. Doing anything else will require adding interface. But adding it may be worthwhile; croaking may be too inconvenient.

What was your use case here? What code did you have to add because of this bug, what code would you have to write if undefs were treated as empty strings, and what code would have you have to write if they triggered exceptions?

from bencode.

mlawren avatar mlawren commented on July 22, 2024

My main use case is serializing simple data structures to hash them for comparison purposes. On one side the Bencode would be constructed by SQLite triggers. On the otherside by Perl. If bencode were to croak on undef then I couldn't use it at all.

My second use case is to inflate the Bencode and do a deeper comparison in the event that the hashes do not match when they should.

If any of my structures contain NULL/undef then Bencode is not actually the right format to use. So from that point of view it appears that croaking on undef is the right thing to do.

from bencode.

grr avatar grr commented on July 22, 2024

The conversation just started and is still ongoing and you're already going to fork it? http://prepan.org/module/nYfNhvSqeC5
BTW, very poor namespace choice.

from bencode.

ap avatar ap commented on July 22, 2024

The conversation just started and is still ongoing and you're already going to fork it? http://prepan.org/module/nYfNhvSqeC5

Heh. I don’t mind actually. It’s… amusingly pointless?

Why pick Bencode when it doesn’t support everything you need? And why not just switch to JSON upon finding out? Using the wrong tool on purpose is sometimes fun… I didn’t get the impression that @mlawren was looking for a diversion here, though.

But through all that, a real omission in Bencode.pm got discovered and pointed out to me, so personally I’m happy.

from bencode.

Related Issues (4)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.