Last active
September 7, 2018 17:24
-
-
Save ssylvan/80debcac11605f357e5a45d7aa55058d to your computer and use it in GitHub Desktop.
Revisions
-
ssylvan revised this gist
Sep 7, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ ctx.Present(); // This is now available. // So basically, shadowing is neat when you have some kind of "protocol" and want to enforce it // statically, because the same "object" can be in different states, represented by changing its // type over time, which lets the compiler catch mistakes. // Without shadowing this gets messier: ctx.ClearScreen(); -
ssylvan created this gist
Sep 7, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ // Example: ctx.ClearScreen(); let ctx = ctx.BeginTriangleStrip(); // Old context is *consumed*, new context has different methods // ctx.ClearScreen(); // ERRROR: not supported on this context ctx.AddVertex(...); ctx.AddVertex(...); ctx.AddVertex(...); let ctx = ctx.End(); ctx.Present(); // This is now available. // So basically, shadowing is neat when you have some kind of "protocol" and want to enforce it // statically, because the same "object" can be in different states, represented by changing its // type throughout the method, which lets the compiler catch mistakes. // Without shadowing this gets messier: ctx.ClearScreen(); let tri_strip_ctx = ctx.BeginTriangleStrip(); tri_strip_ctx.AddVertex(...); tri_strip_ctx.AddVertex(...); tri_strip_ctx.AddVertex(...); // What do we call this? It's conceptually the same as the first ctx.. Should we keep incrementing this number? let ctx2 = tri_strip.End(); ctx2.Present();