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

Distinguishing nested optionals #146

Open
meithecatte opened this issue Oct 15, 2019 · 1 comment
Open

Distinguishing nested optionals #146

meithecatte opened this issue Oct 15, 2019 · 1 comment
Milestone

Comments

@meithecatte
Copy link
Contributor

Consider this example program:

🏁 🍇
  🆕🍯🐚🍬🔢🍆🐸❗ ➡️ 🖍️🆕dict

  1  ➡️ 🐽dict 🔤one🔤❗
  🤷 ➡️ 🐽dict 🔤nope🔤❗

  ↪️ 🐽dict 🔤seventeen🔤❗ ➡️ unwrapped 🍇
    💭 Won't print
    😀 🔤seventeen is in the dictionary🔤❗
  🍉

  ↪️ 🐽dict 🔤nope🔤❗ ➡️ unwrapped 🍇
    💭 Won't print, but perhaps it should?
    😀 🔤nope is in the dictionary🔤❗
  🍉
🍉

I create a dictionary of optional integers. The code above can't distinguish between "Not present in the dictionary" and "The value is 🤷". What is the proper way of achieving this?

@thbwd
Copy link
Member

thbwd commented Mar 10, 2020

The reason for this is a design flaw in the current compiler, which treats optionals very differently from other types when boxing, which is also the reason why casting to optionals is currently not possible. You're right that this behavior is strange and unexpected.

I will look into improving this.

@thbwd thbwd added this to the 1.0 milestone Jul 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants