Hacker News new | past | comments | ask | show | jobs | submit login

What possible reason could someone have for wanting to do this? It is explicitly not recommended in JavaScript:

https://developer.mozilla.org/Web/JavaScript/Reference/Error...

See for yourself:

    > 'use strict'; 01;
    SyntaxError: "0"-prefixed octal literals and octal escape sequences are
    deprecated; for octal literals use the "0o" prefix instead



Octal notation is traditionally used in several contexts - file mode probably being the most common. If you were writing a JSON object to describe a file to be created, and you were under the mistaken impression that JSON supported octal with a leading zero (like most languages), it would be entirely reasonable to write something like:

    {
        "path": "/foo",
        "mode": 0644,
        "contents": "bar"
    }


Yeah ok, but its also explicitly not allowed by the specification, both in text:

> A number is very much like a C or Java number, except that the octal and hexadecimal formats are not used.

and image:

https://json.org/img/number.png

as shown literally on the JSON home page:

https://json.org

I am all for good error handling, but at some point you do have to blame the user.


Error messages are "blaming the user".. its job is to help inform the user the mistake he made.

You can silently beat your child everytime he makes a mistake, until he accidentally does the job correctly (and doesn't get beaten), but it seems to me that making use of our ability to communicate can be much more efficient (and significantly less painful for the child).

And json is merely a (very innefficient, and somewhat problematic) protocol for information exchange; it's not something you should expect people to have read the spec for, especially when its whole popularity stems from it being "intuitive" -- that is, you don't really need to read the spec to deal with it effectively




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: