This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
== Abstract == | |
Introducing possible design of View types (aka refinement types) in D | |
== Rationale == | |
Views (refinement types) are powerful way to express runtime invariants. They help with code deduplication and can simplify error handling. Also, they can enable certain optimizations. | |
== Description == | |
Views are always declared as subtypes of other types, possibly other views: | |
ViewDeclaration: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html lang="en-us"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | |
<title>Emscripten-Generated Code</title> | |
<style> | |
.emscripten { padding-right: 0; margin-left: auto; margin-right: auto; display: block; } | |
textarea.emscripten { font-family: monospace; width: 80%; } | |
div.emscripten { text-align: center; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this is modified example | |
// original is from: http://d.hatena.ne.jp/ABA/20130331#p1 | |
import SDL; | |
import SDL_video; | |
import std.stdio; | |
import std.algorithm; | |
immutable width = 640, height = 480; | |
SDL_Surface *screen; | |
int ticks = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Object-to-object conversion converts each field in turn. Possible conversions are | |
between tuples, structs and classes. Target class must have a default constructor. | |
*/ | |
T toImpl(T, S)(S src) | |
if (!isImplicitlyConvertible!(S, T) && | |
!is(typeof(T(src))) && !is(typeof(new T(src))) && // don't conflict with converting construction | |
!isAssociativeArray!T && !isAssociativeArray!S && // don't conflict with AA conversion | |
!is(typeof(S.init.opCast!T()) : T) && // don't conflict with opCast conversion | |
!is(T == union) && !is(S == union) && // unions not supported |