Title: [compiler] Conditional expressions probably need to return `undefined` by default · Issue #45 · lightscript/lightscript · GitHub
Open Graph Title: [compiler] Conditional expressions probably need to return `undefined` by default · Issue #45 · lightscript/lightscript
X Title: [compiler] Conditional expressions probably need to return `undefined` by default · Issue #45 · lightscript/lightscript
Description: Problem x = if false: 1 // x === null y = (-> if false: 1 )() // y === undefined Wrapping an expression in a function had better not change its value. Proposed Solution While trying to work around JavaScript's proliferation of distinct-y...
Open Graph Description: Problem x = if false: 1 // x === null y = (-> if false: 1 )() // y === undefined Wrapping an expression in a function had better not change its value. Proposed Solution While trying to work around ...
X Description: Problem x = if false: 1 // x === null y = (-> if false: 1 )() // y === undefined Wrapping an expression in a function had better not change its value. Proposed Solution While trying to work arou...
Opengraph URL: https://github.com/lightscript/lightscript/issues/45
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[compiler] Conditional expressions probably need to return `undefined` by default","articleBody":"## Problem\r\n```js\r\nx = if false: 1\r\n// x === null\r\n\r\ny = (-\u003e\r\n if false:\r\n 1\r\n)()\r\n// y === undefined\r\n```\r\n\r\nWrapping an expression in a function had better not change its value.\r\n\r\n## Proposed Solution\r\n\r\nWhile trying to work around JavaScript's proliferation of distinct-yet-falsy values may be noble in spirit, the fact that JavaScript returns `undefined` by default basically forces LSC to do the same for consistency's sake. I think unprovided branches of conditional expressions (`if`, and possibly `match` if it doesn't throw-on-else) should be returning `undefined` to match up with JavaScript core function behavior.\r\n","author":{"url":"https://github.com/wcjohnson","@type":"Person","name":"wcjohnson"},"datePublished":"2017-09-05T21:48:46.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/45/lightscript/issues/45"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6dd31838-e6fc-bff6-ec4e-ae6c62398bd3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | EDA6:3CF864:10116B3:154150F:6A51A40A |
| html-safe-nonce | 5c90cecea83f994f858e83b7d76981e1f6c66a03e6b8b52c7fb88ea67c51c72c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREE2OjNDRjg2NDoxMDExNkIzOjE1NDE1MEY6NkE1MUE0MEEiLCJ2aXNpdG9yX2lkIjoiMjU2MzMzNDYwMjU2NDQxMjQyNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 639caf6dd8643e202f75175e2fd4a25975a5dd7f3ee645357c964fface0fbfde |
| hovercard-subject-tag | issue:255419147 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/lightscript/lightscript/45/issue_layout |
| twitter:image | https://opengraph.githubassets.com/eaa69453207b3034450f9958f0b20d8c828c476139ebd10a405e2892259f0a81/lightscript/lightscript/issues/45 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/eaa69453207b3034450f9958f0b20d8c828c476139ebd10a405e2892259f0a81/lightscript/lightscript/issues/45 |
| og:image:alt | Problem x = if false: 1 // x === null y = (-> if false: 1 )() // y === undefined Wrapping an expression in a function had better not change its value. Proposed Solution While trying to work around ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | wcjohnson |
| hostname | github.com |
| expected-hostname | github.com |
| None | b9a586c06a05a7a86fc7e3f4dbd03e42f6869085879aa184aa6369456dbd50fb |
| turbo-cache-control | no-preview |
| go-import | github.com/lightscript/lightscript git https://github.com/lightscript/lightscript.git |
| octolytics-dimension-user_id | 20427295 |
| octolytics-dimension-user_login | lightscript |
| octolytics-dimension-repository_id | 63191213 |
| octolytics-dimension-repository_nwo | lightscript/lightscript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 63191213 |
| octolytics-dimension-repository_network_root_nwo | lightscript/lightscript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 7aed05249554b889eb33d002851a973eebcc7e91 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width