TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Representing Heterogeneous Data

27 点作者 grep_it将近 2 年前

3 条评论

DylanSp将近 2 年前
New Bob Nystrom blog post! Always going to upvote that.<p>More substantially, I was thinking of Typescript&#x27;s control flow analysis as soon as I started reading through the &quot;Record cases&quot; section, I was already thinking of commenting on it, and then the next section anticipated my thoughts. I can definitely understand that being difficult to implement in the general case, but I&#x27;m curious if it&#x27;d be workable within the context of a single statement&#x2F;expression. I&#x27;m envisioning something like Go&#x27;s .(type) syntax. You&#x27;d probably need to restrict what would be allowed within each case branch, though, and that could get tricky and unintuitive to use.
mndrix将近 2 年前
His solution and syntax remind me of Ada&#x27;s variant records. Despite Ada&#x27;s focus on safety, it also resorts to runtime exceptions for incompatible fields in that case. That&#x27;s probably a local maximum in the language design space.
评论 #37029529 未加载
orange-tourist将近 2 年前
&gt; imagine you have a record for storing a street address<p>In my experience these are all strings. Try storing a UK postcode as an int or a value like &quot;1B&quot; in an apartment number.