TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Representing Heterogeneous Data

27 pointsby grep_italmost 2 years ago

3 comments

DylanSpalmost 2 years ago
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.
mndrixalmost 2 years ago
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-touristalmost 2 years ago
&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.