strawman proposal for base4 and base 32 integer literals

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

strawman proposal for base4 and base 32 integer literals

Shaun Moss
Hi all

I'm new to the list so please forgive me if I breach etiquette.

I have drafted a proposal for addition to the ES spec: https://github.com/mossy2100/ecmascript/blob/master/base4and32literals.md

If anyone has a few spare minutes, I'd be grateful if you could please give it a quick look over. I'd really appreciate any feedback on how to improve or advance it. I haven't looked into implementation details yet but I will soon.

Thank you
Shaun


--
Have a great day!
Shaun Moss

+61 (0) 434 704596
Skype: mossy2100

Author: "The International Mars Research Station - An exciting new plan to create a permanent human presence on Mars" (https://marsbase.org)
Author: "Practical Metaphysics" (http://practicalmetaphysicsbook.com)
Creator: "The Utopian Calendar" - Possibly the best calendar for Mars ever designed. (https://marscalendar.com)
Creator: "The Earthian Calendar" - Possibly the best calendar for Earth ever designed. (http://earthiancalendar.info)


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: strawman proposal for base4 and base 32 integer literals

Peter Jaszkowiak
You don't have nearly enough discussion of use cases. Without that, especially since `parseInt(str, radix)` already exists, this is unlikely to go anywhere. Also, your base32 system is inconsistent with how `parseInt(str, 32)` currently behaves, which further decreases the likelihood of it being accepted.

Base 4 has few use cases because it only saves 1 character per bit-couple. 

On Sun, Oct 7, 2018, 18:51 Shaun Moss <[hidden email]> wrote:
Hi all

I'm new to the list so please forgive me if I breach etiquette.

I have drafted a proposal for addition to the ES spec: https://github.com/mossy2100/ecmascript/blob/master/base4and32literals.md

If anyone has a few spare minutes, I'd be grateful if you could please give it a quick look over. I'd really appreciate any feedback on how to improve or advance it. I haven't looked into implementation details yet but I will soon.

Thank you
Shaun


--
Have a great day!
Shaun Moss

+61 (0) 434 704596
Skype: mossy2100

Author: "The International Mars Research Station - An exciting new plan to create a permanent human presence on Mars" (https://marsbase.org)
Author: "Practical Metaphysics" (http://practicalmetaphysicsbook.com)
Creator: "The Utopian Calendar" - Possibly the best calendar for Mars ever designed. (https://marscalendar.com)
Creator: "The Earthian Calendar" - Possibly the best calendar for Earth ever designed. (http://earthiancalendar.info)

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: strawman proposal for base4 and base 32 integer literals

Shaun Moss
The second point is very helpful, thank you, Peter. I didn't realise that parseInt() already parsed letters A-V as values 10-31. Obviously any syntax for literals would need to be compatible with this (it's the same as the base32hex proposal in RFC 2938).

Thank you
Shaun



On Mon, 8 Oct 2018 at 10:58, Peter Jaszkowiak <[hidden email]> wrote:
You don't have nearly enough discussion of use cases. Without that, especially since `parseInt(str, radix)` already exists, this is unlikely to go anywhere. Also, your base32 system is inconsistent with how `parseInt(str, 32)` currently behaves, which further decreases the likelihood of it being accepted.

Base 4 has few use cases because it only saves 1 character per bit-couple. 

On Sun, Oct 7, 2018, 18:51 Shaun Moss <[hidden email]> wrote:
Hi all

I'm new to the list so please forgive me if I breach etiquette.

I have drafted a proposal for addition to the ES spec: https://github.com/mossy2100/ecmascript/blob/master/base4and32literals.md

If anyone has a few spare minutes, I'd be grateful if you could please give it a quick look over. I'd really appreciate any feedback on how to improve or advance it. I haven't looked into implementation details yet but I will soon.

Thank you
Shaun


--
Have a great day!
Shaun Moss

+61 (0) 434 704596
Skype: mossy2100

Author: "The International Mars Research Station - An exciting new plan to create a permanent human presence on Mars" (https://marsbase.org)
Author: "Practical Metaphysics" (http://practicalmetaphysicsbook.com)
Creator: "The Utopian Calendar" - Possibly the best calendar for Mars ever designed. (https://marscalendar.com)
Creator: "The Earthian Calendar" - Possibly the best calendar for Earth ever designed. (http://earthiancalendar.info)

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss


--
Have a great day!
Shaun Moss

+61 (0) 434 704596
Skype: mossy2100

Author: "The International Mars Research Station - An exciting new plan to create a permanent human presence on Mars" (https://marsbase.org)
Author: "Practical Metaphysics" (http://practicalmetaphysicsbook.com)
Creator: "The Utopian Calendar" - Possibly the best calendar for Mars ever designed. (https://marscalendar.com)
Creator: "The Earthian Calendar" - Possibly the best calendar for Earth ever designed. (http://earthiancalendar.info)


_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: strawman proposal for base4 and base 32 integer literals

Carsten Bormann
On Oct 8, 2018, at 06:14, Shaun Moss <[hidden email]> wrote:
>
> base32hex proposal in RFC 2938

There are lots of “base 32” encodings.  The most definitive document here is RFC 4648, which provides “base32” (alphabet “ABCDEFGHIJKLMNOPQRSTUVWXYZ234567”, which is closer to base64) in addition to the above (“0123456789ABCDEFGHIJKLMNOPQRSTUV”) which is called “base32hex” there as well.  There is also a (different) “base32” in RFC 6189, with the alphabet “ybndrfg8ejkmcpqxot1uwisza345h769”, and tons of ones defined in specific applications.  Any useful base32 function probably should take the alphabet as an argument.  A base32 decoder may (or may not) want to be case-insensitive.

Grüße, Carsten

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss
Reply | Threaded
Open this post in threaded view
|

Re: strawman proposal for base4 and base 32 integer literals

kdex
In reply to this post by Shaun Moss
Sorry, but I highly doubt that it's worth reserving syntax for two bases for
which even the author suggests their lesser usefulness.

This is best kept in user-space. Base-4 numbers should already be covered by
this[1] proposal.

As for base 32, Carsten has already pointed out the problem of non-unique
encodings (and this is true for every radix greater than 10).

If (your specific encoding of) base-32 literals were to be implemented in
user-space, I think we could get away with extensible string literals, i.e.
something akin to:

```js
const base32 = string => { /* …  */ };
console.log("10"_base32); // logs 32
```

[1] https://github.com/tc39/proposal-extended-numeric-literals

On Monday, October 8, 2018 2:51:04 AM CEST Shaun Moss wrote:

> Hi all
>
> I'm new to the list so please forgive me if I breach etiquette.
>
> I have drafted a proposal for addition to the ES spec:
> https://github.com/mossy2100/ecmascript/blob/master/base4and32literals.md
>
> If anyone has a few spare minutes, I'd be grateful if you could please give
> it a quick look over. I'd really appreciate any feedback on how to improve
> or advance it. I haven't looked into implementation details yet but I will
> soon.
>
> Thank you
> Shaun
_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

signature.asc (849 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: strawman proposal for base4 and base 32 integer literals

Bob Myers
Why not used a tagged template literal, as in

```
base32`123EFG`
```

Bob


On Mon, Oct 8, 2018 at 1:05 PM kdex <[hidden email]> wrote:
Sorry, but I highly doubt that it's worth reserving syntax for two bases for
which even the author suggests their lesser usefulness.

This is best kept in user-space. Base-4 numbers should already be covered by
this[1] proposal.

As for base 32, Carsten has already pointed out the problem of non-unique
encodings (and this is true for every radix greater than 10).

If (your specific encoding of) base-32 literals were to be implemented in
user-space, I think we could get away with extensible string literals, i.e.
something akin to:

```js
const base32 = string => { /* …  */ };
console.log("10"_base32); // logs 32
```

[1] https://github.com/tc39/proposal-extended-numeric-literals

On Monday, October 8, 2018 2:51:04 AM CEST Shaun Moss wrote:
> Hi all
>
> I'm new to the list so please forgive me if I breach etiquette.
>
> I have drafted a proposal for addition to the ES spec:
> https://github.com/mossy2100/ecmascript/blob/master/base4and32literals.md
>
> If anyone has a few spare minutes, I'd be grateful if you could please give
> it a quick look over. I'd really appreciate any feedback on how to improve
> or advance it. I haven't looked into implementation details yet but I will
> soon.
>
> Thank you
> Shaun_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss

_______________________________________________
es-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es-discuss