Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add binary literals #8275

Open
wants to merge 2 commits into
base: 2.13.x
from

Conversation

@NthPortal
Copy link
Contributor

commented Jul 28, 2019

No description provided.

@NthPortal NthPortal requested a review from som-snytt Jul 28, 2019

@scala-jenkins scala-jenkins added this to the 2.13.1 milestone Jul 28, 2019

@NthPortal

This comment has been minimized.

Copy link
Contributor Author

commented Jul 28, 2019

check_success("0b_1100 == 0xc", 0b_1100, 0xc)
check_success("0b_1101 == 0xd", 0b_1101, 0xd)
check_success("0b_1110 == 0xe", 0b_1110, 0xe)
check_success("0b_1111 == 0xf", 0b_1111, 0xf)

This comment has been minimized.

Copy link
@som-snytt

som-snytt Jul 28, 2019

Contributor

What, no 0b_1111_1111?

This comment has been minimized.

Copy link
@NthPortal

NthPortal Jul 28, 2019

Author Contributor

that's uhh... 16 times as long >.>

This comment has been minimized.

Copy link
@NthPortal

NthPortal Jul 28, 2019

Author Contributor

what I actually should have tested is 0b1 // Kenobi

@som-snytt

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2019

Here is a branch https://github.com/som-snytt/scala/tree/review/binary-literals and commit som-snytt@d385d95 showing the small delta atop my other PR.

@som-snytt
Copy link
Contributor

left a comment

This will look even better rebased on my other clean-up PR in scanners.

@som-snytt

This comment has been minimized.

Copy link
Contributor

commented Jul 28, 2019

I also checked

scala> 0b1000100010001000_1000100010001000_1
       ^
       error: integer number too large

scala> 0b1000100010001000_1000100010001000_1000100010001000_1000100010001000L
res0: Long = -8608480567731124088

scala> 0b1000100010001000_1000100010001000_1000100010001000_1000100010001000_0L
       ^
       error: integer number too large

Maybe I'll take a few minutes this week to understand the overflow check.

I was curious if there's an internal limit, but it's commented out:

    protected def putChar(c: Char): Unit = {
//      assert(cbuf.size < 10000, cbuf)
      cbuf.append(c)
    }

where cbuf is a StringBuilder not an array.

NthPortal added some commits Jul 28, 2019

@NthPortal NthPortal force-pushed the NthPortal:topic/binary-literals/PR branch from 2dcacfb to d82ea91 Jul 28, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.