FAQ
Hi.

I have noted that Go syntax is missing some simply and useful features that
are
available in some "modern" programming languages.

1) Hex floating point literal.
     I have started to use hex float literals in C99 (for unit testing), and
they
     seems to be very useful. AFAIK they are only available in very few
languages.

2) Uniform syntax for integer literals.
     Some new programming languages have an uniform and very readable
     syntax for integer literals, as an example,
      - a decimal number has no prefix
      - a binary number has a 0b prefix
      - an octal number has an 0o prefix
      - an hexadecimal number has a 0x prefix

      From my experience, the 0o prefix is very important for code
readability,
      and support for binary numbers is useful

This question has been surely already posted in the past, but what is the
reason why
Go does not support there features?


Thanks Manlio Perillo

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Dave Cheney at Dec 10, 2014 at 1:36 pm
    You can already express these constructs easily and without ambiguity in the language that exists today. Yet another way to expresses literals would not pay for itself.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Volker Dobler at Dec 10, 2014 at 1:55 pm

    Am Mittwoch, 10. Dezember 2014 14:19:27 UTC+1 schrieb Manlio Perillo:
    [...]
    1) Hex floating point literal.
    I have started to use hex float literals in C99 (for unit testing),
    and they
    seems to be very useful. AFAIK they are only available in very few
    languages.
    Given that Go literals are of very high precision I am not
    convinced this is really helpful.

    2) Uniform syntax for integer literals.
    Some new programming languages have an uniform and very readable
    syntax for integer literals, as an example,
    - a decimal number has no prefix
    - a binary number has a 0b prefix
    - an octal number has an 0o prefix
    - an hexadecimal number has a 0x prefix
    All except binary literals are already supported and some line has
    to be drawn; otherwise someone will demand support for vigesimal
    literals because it would be convenient during transcription of
    Mayaen calendars.

    V.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michael Jones at Dec 10, 2014 at 3:33 pm
    It is not about "modern" languages at all. Non-decimal integer literals are
    a convenience that have been around in many forms for 50+ years.

    The heritage of pre-C computers had one (PDP-8) where use of octal made
    special sense so the developers of C were comfortable with that and added
    special "leading zero means octal" code. When PCC/UNIX moved to the
    Interdata 8/32 they wanted hexadecimal and thus "0x" (they may have had hex
    before, but big octal constants were popular on the PDP-11 even though it
    hex would have been more natural). They never met any other big needs so
    BTL stopped there.

    In other realms, unifying the idea of flexible radix was a popular topic.
    There are a few schools of thought, the prefix camp and the postfix camps
    and the radix in decimal and radix coded as a symbol approaches. Manlio
    listed a prefix-symbol approach. Another way that I'm fond of is the
    'radix' coding scheme:

    123 => 123
    10r123 => "123" in radix 10 == 123 decimal
    16r123 => "123" in radix 16 == 291 decimal
    16rFACE => "FACE" in radix 16 == 64206 decimal

    I like this because it is regular, does not give leading zeroes magic
    meaning, and because it is general for bases 2 through 36.

    The language Ada had a nice addition for integer literals, the "don't care"
    underscore. The rule is that "_" within numbers is ignored. This means you
    can write the literal 16_777_216 for the value of 2**24, using the
    underscore for [,.]. I like it much better than a long string of digits. It
    did not catch on outside Ada though. Pitty!

    Michael

    On Wed, Dec 10, 2014 at 5:55 AM, Volker Dobler wrote:

    Am Mittwoch, 10. Dezember 2014 14:19:27 UTC+1 schrieb Manlio Perillo:
    [...]
    1) Hex floating point literal.
    I have started to use hex float literals in C99 (for unit testing),
    and they
    seems to be very useful. AFAIK they are only available in very few
    languages.
    Given that Go literals are of very high precision I am not
    convinced this is really helpful.

    2) Uniform syntax for integer literals.
    Some new programming languages have an uniform and very readable
    syntax for integer literals, as an example,
    - a decimal number has no prefix
    - a binary number has a 0b prefix
    - an octal number has an 0o prefix
    - an hexadecimal number has a 0x prefix
    All except binary literals are already supported and some line has
    to be drawn; otherwise someone will demand support for vigesimal
    literals because it would be convenient during transcription of
    Mayaen calendars.

    V.

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.


    --
    *Michael T. Jones | Chief Technology Advocate | mtj@google.com
    <mtj@google.com> | +1 650-335-5765*

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Andrey mirtchovski at Dec 10, 2014 at 4:07 pm

    In other realms, unifying the idea of flexible radix was a popular topic.
    There are a few schools of thought, the prefix camp and the postfix camps
    and the radix in decimal and radix coded as a symbol approaches. Manlio
    listed a prefix-symbol approach. Another way that I'm fond of is the 'radix'
    coding scheme:

    123 => 123
    10r123 => "123" in radix 10 == 123 decimal
    16r123 => "123" in radix 16 == 291 decimal
    16rFACE => "FACE" in radix 16 == 64206 decimal
    Limbo used this scheme, if you're looking for a direct (if dotted) line to Go.

    see 2.4.1: http://doc.cat-v.org/inferno/4th_edition/limbo_language/limbo

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Milan P. Stanic at Dec 10, 2014 at 5:03 pm

    On Wed, 2014-12-10 at 07:33, 'Michael Jones' via golang-nuts wrote:
    It is not about "modern" languages at all. Non-decimal integer literals are
    a convenience that have been around in many forms for 50+ years.

    The heritage of pre-C computers had one (PDP-8) where use of octal made
    special sense so the developers of C were comfortable with that and added
    special "leading zero means octal" code. When PCC/UNIX moved to the
    Interdata 8/32 they wanted hexadecimal and thus "0x" (they may have had hex
    before, but big octal constants were popular on the PDP-11 even though it
    hex would have been more natural). They never met any other big needs so
    BTL stopped there.

    In other realms, unifying the idea of flexible radix was a popular topic.
    There are a few schools of thought, the prefix camp and the postfix camps
    and the radix in decimal and radix coded as a symbol approaches. Manlio
    listed a prefix-symbol approach. Another way that I'm fond of is the
    'radix' coding scheme:

    123 => 123
    10r123 => "123" in radix 10 == 123 decimal
    16r123 => "123" in radix 16 == 291 decimal
    16rFACE => "FACE" in radix 16 == 64206 decimal

    I like this because it is regular, does not give leading zeroes magic
    meaning, and because it is general for bases 2 through 36.

    The language Ada had a nice addition for integer literals, the "don't care"
    underscore. The rule is that "_" within numbers is ignored. This means you
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Perl, too.
    can write the literal 16_777_216 for the value of 2**24, using the
    underscore for [,.]. I like it much better than a long string of digits. It
    did not catch on outside Ada though. Pitty!
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Drj at Dec 10, 2014 at 5:35 pm

    Am Mittwoch, 10. Dezember 2014 18:04:22 UTC+1 schrieb mps:
    On Wed, 2014-12-10 at 07:33, 'Michael Jones' via golang-nuts wrote:
    It is not about "modern" languages at all. Non-decimal integer literals are
    a convenience that have been around in many forms for 50+ years.

    The heritage of pre-C computers had one (PDP-8) where use of octal made
    special sense so the developers of C were comfortable with that and added
    special "leading zero means octal" code. When PCC/UNIX moved to the
    Interdata 8/32 they wanted hexadecimal and thus "0x" (they may have had hex
    before, but big octal constants were popular on the PDP-11 even though it
    hex would have been more natural). They never met any other big needs so
    BTL stopped there.

    In other realms, unifying the idea of flexible radix was a popular topic.
    There are a few schools of thought, the prefix camp and the postfix camps
    and the radix in decimal and radix coded as a symbol approaches. Manlio
    listed a prefix-symbol approach. Another way that I'm fond of is the
    'radix' coding scheme:

    123 => 123
    10r123 => "123" in radix 10 == 123 decimal
    16r123 => "123" in radix 16 == 291 decimal
    16rFACE => "FACE" in radix 16 == 64206 decimal

    I like this because it is regular, does not give leading zeroes magic
    meaning, and because it is general for bases 2 through 36.

    The language Ada had a nice addition for integer literals, the "don't care"
    underscore. The rule is that "_" within numbers is ignored. This means
    you
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Perl, too.
    The D programming language has this feature too.

    -david

    can write the literal 16_777_216 for the value of 2**24, using the
    underscore for [,.]. I like it much better than a long string of digits. It
    did not catch on outside Ada though. Pitty!
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Manlio Perillo at Dec 12, 2014 at 10:52 am
    Il giorno mercoledì 10 dicembre 2014 18:35:15 UTC+1, drj ha scritto:


    Am Mittwoch, 10. Dezember 2014 18:04:22 UTC+1 schrieb mps:
    On Wed, 2014-12-10 at 07:33, 'Michael Jones' via golang-nuts wrote:
    It is not about "modern" languages at all. Non-decimal integer literals are
    a convenience that have been around in many forms for 50+ years. [...]
    In other realms, unifying the idea of flexible radix was a popular
    topic.
    There are a few schools of thought, the prefix camp and the postfix
    camps
    and the radix in decimal and radix coded as a symbol approaches. Manlio
    listed a prefix-symbol approach. Another way that I'm fond of is the
    'radix' coding scheme:

    123 => 123
    10r123 => "123" in radix 10 == 123 decimal
    16r123 => "123" in radix 16 == 291 decimal
    16rFACE => "FACE" in radix 16 == 64206 decimal
    Right, I forgot about this scheme; thanks.

    Hoever Go is using a prefix scheme; the problem is that it is not regular
    due to
    how octal integer literals are encoded. Using 0o prefix would make it more
    regular,
    and, more important, more readable.

    Binary literals support is not really required, but it, again, helps
    readability.
    [...]

    Regards Manlio Perillo

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Michael Jones at Dec 12, 2014 at 12:09 pm
    I argued for binary literals way back when.
    On Fri, Dec 12, 2014 at 2:52 AM, Manlio Perillo wrote:

    Il giorno mercoledì 10 dicembre 2014 18:35:15 UTC+1, drj ha scritto:


    Am Mittwoch, 10. Dezember 2014 18:04:22 UTC+1 schrieb mps:
    On Wed, 2014-12-10 at 07:33, 'Michael Jones' via golang-nuts wrote:
    It is not about "modern" languages at all. Non-decimal integer
    literals are
    a convenience that have been around in many forms for 50+ years. [...]
    In other realms, unifying the idea of flexible radix was a popular
    topic.
    There are a few schools of thought, the prefix camp and the postfix
    camps
    and the radix in decimal and radix coded as a symbol approaches. Manlio
    listed a prefix-symbol approach. Another way that I'm fond of is the
    'radix' coding scheme:

    123 => 123
    10r123 => "123" in radix 10 == 123 decimal
    16r123 => "123" in radix 16 == 291 decimal
    16rFACE => "FACE" in radix 16 == 64206 decimal
    Right, I forgot about this scheme; thanks.

    Hoever Go is using a prefix scheme; the problem is that it is not regular
    due to
    how octal integer literals are encoded. Using 0o prefix would make it
    more regular,
    and, more important, more readable.

    Binary literals support is not really required, but it, again, helps
    readability.
    [...]

    Regards Manlio Perillo

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

    --
    *Michael T. Jones | Chief Technology Advocate | mtj@google.com
    <mtj@google.com> | +1 650-335-5765*

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Mateusz Czapliński at Dec 17, 2014 at 12:07 am

    On Wednesday, December 10, 2014 6:35:15 PM UTC+1, drj wrote:


    Am Mittwoch, 10. Dezember 2014 18:04:22 UTC+1 schrieb mps:
    On Wed, 2014-12-10 at 07:33, 'Michael Jones' via golang-nuts wrote:
    The language Ada had a nice addition for integer literals, the "don't care"
    underscore. The rule is that "_" within numbers is ignored. [...]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Perl, too.
    The D programming language has this feature too.
    Aaaand, apparently, Rust's gonna have this too.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Rob Pike at Dec 17, 2014 at 12:15 am
    Go doesn't have it.

    -rob

    On Wed, Dec 17, 2014 at 9:07 AM, Mateusz Czapliński wrote:


    On Wednesday, December 10, 2014 6:35:15 PM UTC+1, drj wrote:



    Am Mittwoch, 10. Dezember 2014 18:04:22 UTC+1 schrieb mps:
    On Wed, 2014-12-10 at 07:33, 'Michael Jones' via golang-nuts wrote:
    The language Ada had a nice addition for integer literals, the "don't care"
    underscore. The rule is that "_" within numbers is ignored. [...]
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Perl, too.
    The D programming language has this feature too.
    Aaaand, apparently, Rust's gonna have this too.

    --
    You received this message because you are subscribed to the Google Groups
    "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Dave Cheney at Dec 17, 2014 at 12:16 am
    If Rust jumped off a bridge, would you too? Seriously, what sort of an argument is that? Go clearly isn't a language that wants to compete for the length of its feature list.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedDec 10, '14 at 1:19p
activeDec 17, '14 at 12:16a
posts12
users9
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase