Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
hoseja
39 days ago
|
parent
|
context
|
favorite
| on:
Why F#?
weak typing: 2 + "2" is 22
RUnconcerned
38 days ago
[–]
could also be "4" or 4! 4 seems like it would be the most evil option, honestly
pjc50
38 days ago
|
parent
|
next
[–]
The real evil option is C: 2+"22" = 0, 4+"4" = undefined behavior and probably the value of some other variable.
sehansen
38 days ago
|
root
|
parent
|
next
[–]
The real horror is "1d9" + 1 = 2, as does PHP:
https://3v4l.org/Dn6Sm
manwe150
38 days ago
|
root
|
parent
|
prev
|
next
[–]
I think you meant: "22"+2 = "", and it is not UB to make the second pointer, only to use it
hoseja
33 days ago
|
root
|
parent
|
next
[–]
The pointer arithmetic works both ways, same as square brackets.
baq
38 days ago
|
parent
|
prev
[–]
or the most sane, depending on context... e.g. awk and perl do this.
Consider applying for YC's Summer 2025 batch! Applications are open till May 13
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: