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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Idris: Type safe printf [video]

54 点作者 kenhty超过 10 年前

7 条评论

bronty超过 10 年前
You can check format strings in Java at compile-time using the Checker Framework: <a href="http://types.cs.washington.edu/checker-framework/current/checker-framework-manual.html#formatter-checker" rel="nofollow">http:&#x2F;&#x2F;types.cs.washington.edu&#x2F;checker-framework&#x2F;current&#x2F;che...</a><p>The format string semantics are actually pretty tricky because printf will perform conversions in certain cases.
latkin超过 10 年前
Very cool, Idris looks like a really interesting language.<p>F#&#x27;s standard printf-family functions are all type-safe in exactly the same way. This requires special support by the compiler, though, as F#&#x27;s type system is not as powerful. Most of the plumbing is standard, but the conversion from string literal to PrintfFormat at compile time is only possible due to hardcoded magic. You can&#x27;t get exactly the same effect from plain user code, though you could certainly get something very close using a Type Provider (the syntax would just be a bit clunkier).
评论 #8807391 未加载
ufo超过 10 年前
Why define Format as<p><pre><code> data Format = FInt Format | FString Format | FOther Char Format | FEnd </code></pre> instead of using lists?<p><pre><code> data FormatPart = FInt | FString | FOther Char type Format = List FormatPart</code></pre>
评论 #8806310 未加载
wheaties超过 10 年前
This was awesome and yet one more reason to learn Idris. Now I have to see if it can be done in Scala.
评论 #8806442 未加载
wz1000超过 10 年前
Really cool, but I am assuming printf only works for values which are determined at compile time?
评论 #8806255 未加载
ExpiredLink超过 10 年前
Idris?
评论 #8805850 未加载
socceroos超过 10 年前
My mind immediately went to Star Citizen...
评论 #8806161 未加载