SHA1 Hash: | 474c4facf0a5727168ecca3177fab903e2231b1d |
---|---|
Date: | 2010-11-25 12:32:41 |
User: | kinaba |
Comment: | Introduced makefile to build documents. sample/macro.pmy is fully reformed. print(x) now returns x, not 0. |
Timelines: | family | ancestors | descendants | both | trunk |
Downloads: | Tarball | ZIP archive |
Other Links: | files | file ages | manifest |
- branch=trunk inherited from [f65680e1d2]
- sym-trunk inherited from [f65680e1d2]
Modified .poseidon from [836851406ea9429f] to [76daaad38468db8e].
47 47 <name>tricks\tricks.d</name> 48 48 </source> 49 49 <interface /> 50 50 <resource /> 51 51 <othersDMD /> 52 52 <others> 53 53 <name>build.bat</name> 54 - <name>build.sh</name> 55 - <name>builddoc.bat</name> 56 54 <name>doc\candydoc\modules.ddoc</name> 57 55 <name>index.dd</name> 58 56 <name>readme.txt</name> 59 57 </others> 60 58 </projectFiles> 61 59 <includePaths /> 62 60 <linkLibrarys /> 63 61 <importExpressions /> 64 62 </buildSpec> 65 63 </projectDescription>
Added Makefile version [300aa94f95ae54a3]
1 +.PHONY : all windows doc 2 + 3 +DC=dmd 4 +DC_OPT=-O -release 5 +SRC = $(wildcard *.d polemy/*.d tricks/*.d) 6 + 7 + 8 +all: 9 + $(DC) $(DC_OPT) -ofbin/polemy $(SRC) 10 + 11 +windows: 12 + $(DC) $(DC_OPT) -ofbin\\polemy $(SRC) 13 + 14 + 15 + 16 + 17 +DOCDIR=doc 18 +DDOC_FILES=$(DOCDIR)/candydoc/candy.ddoc $(DOCDIR)/candydoc/modules.ddoc 19 +DDOC_OPT=-o- -D -Dddoc $(DDOC_FILES) 20 + 21 +VPATH = . polemy tricks 22 + 23 +$(DOCDIR)/%.html: %.d $(DDOC_FILES) 24 + $(DC) $(DDOC_OPT) $< 25 + 26 +$(DOCDIR)/%.html: %.dd $(DDOC_FILES) 27 + $(DC) $(DDOC_OPT) $< 28 + 29 +SRCB = $(notdir $(SRC)) 30 +SRCA = $(addprefix $(DOCDIR)/, $(SRCB)) 31 +DOCS = $(SRCA:.d=.html) $(DOCDIR)/index.html 32 + 33 +doc: $(DOCS)
Deleted build.sh version [34b93de3231b69af]
1 -#!/bin/sh 2 -if [ ! -d bin ]; then mkdir bin; fi 3 -echo dmd -ofbin/polemy -O -release main.d polemy/*.d tricks/*.d 4 -dmd -ofbin/polemy -O -release main.d polemy/*.d tricks/*.d
Deleted builddoc.bat version [3483396bbcf61fe3]
1 -@setlocal ENABLEDELAYEDEXPANSION 2 -@set ARGS= 3 -@for %%I in (main.d polemy\*.d tricks\*.d) do @set ARGS=!ARGS! %%I 4 -@if not exist bin mkdir bin 5 -@echo dmd -o- -D -Dddoc index.dd doc\candydoc\candy.ddoc doc\candydoc\modules.ddoc %ARGS% 6 -@dmd -o- -D -Dddoc index.dd doc\candydoc\candy.ddoc doc\candydoc\modules.ddoc %ARGS%
Modified doc/_common.html from [4967f08e96ea62fb] to [9340890a47c908ed].
22 22 23 23 The list of modules globaly used inside Polemy.<br><br> 24 24 25 25 </td></tr> 26 26 <tr><td id="docfooter"> 27 27 Page was generated with 28 28 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 29 - on Wed Nov 24 21:12:49 2010 29 + on Thu Nov 25 12:13:45 2010 30 30 31 31 </td></tr> 32 32 </table> 33 33 </div> 34 34 <script> 35 35 explorer.packageExplorer.addModule("index"); 36 36 explorer.packageExplorer.addModule("main");
Modified doc/ast.html from [abe7fd96d97ab5fa] to [378b6fe37d6f4ecd].
563 563 <script>explorer.outline.decSymbolLevel();</script> 564 564 565 565 566 566 </td></tr> 567 567 <tr><td id="docfooter"> 568 568 Page was generated with 569 569 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 570 - on Wed Nov 24 21:12:49 2010 570 + on Thu Nov 25 12:13:46 2010 571 571 572 572 </td></tr> 573 573 </table> 574 574 </div> 575 575 <script> 576 576 explorer.packageExplorer.addModule("index"); 577 577 explorer.packageExplorer.addModule("main");
Modified doc/eval.html from [8cb6c47f9236dfb9] to [694d60ab663f1749].
128 128 <script>explorer.outline.decSymbolLevel();</script> 129 129 130 130 131 131 </td></tr> 132 132 <tr><td id="docfooter"> 133 133 Page was generated with 134 134 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 135 - on Wed Nov 24 21:12:49 2010 135 + on Thu Nov 25 12:13:46 2010 136 136 137 137 </td></tr> 138 138 </table> 139 139 </div> 140 140 <script> 141 141 explorer.packageExplorer.addModule("index"); 142 142 explorer.packageExplorer.addModule("main");
Modified doc/failure.html from [ad8b9e8445bd882d] to [40513c24ea54cf40].
178 178 <script>explorer.outline.decSymbolLevel();</script> 179 179 180 180 181 181 </td></tr> 182 182 <tr><td id="docfooter"> 183 183 Page was generated with 184 184 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 185 - on Wed Nov 24 21:12:49 2010 185 + on Thu Nov 25 12:13:47 2010 186 186 187 187 </td></tr> 188 188 </table> 189 189 </div> 190 190 <script> 191 191 explorer.packageExplorer.addModule("index"); 192 192 explorer.packageExplorer.addModule("main");
Modified doc/fresh.html from [9086e73b015a5783] to [c181d051b30c5ddc].
46 46 <script>explorer.outline.decSymbolLevel();</script> 47 47 48 48 49 49 </td></tr> 50 50 <tr><td id="docfooter"> 51 51 Page was generated with 52 52 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 53 - on Wed Nov 24 21:12:49 2010 53 + on Thu Nov 25 12:13:47 2010 54 54 55 55 </td></tr> 56 56 </table> 57 57 </div> 58 58 <script> 59 59 explorer.packageExplorer.addModule("index"); 60 60 explorer.packageExplorer.addModule("main");
Modified doc/index.html from [f03a1357a018cf8a] to [720b71facce28489].
765 765 <dt><span class="decl"> 766 766 <span class="currsymbol">外部とのやりとり</span> 767 767 <script>explorer.outline.addDecl('外部とのやりとり');</script> 768 768 769 769 </span></dt> 770 770 <script>explorer.outline.writeEnabled = false;</script> 771 771 772 - <dd> <table> <tr><th>print</th> <td>(a)</td> <td>a を文字列化標準出力に改行付きで表示</td></tr> 772 + <dd> <table> <tr><th>print</th> <td>(a)</td> <td>a を文字列化標準出力に改行付きで表示して、a を返す</td></tr> 773 773 <tr><th>argv</th> <td></td> <td>スクリプトに渡された引数文字列のconsリスト</td></tr> 774 + <tr><th>gensym</th> <td>()</td> <td>エセgensym。変数名として他とかぶらなそうな文字列を返します</td></tr> 775 + <tr><th>rand</th> <td>(n)</td> <td>0 以上 n 未満の自然数を31bit以内でランダムに生成します</td></tr> 774 776 </table> 775 777 </dd> 776 778 <br /> 777 779 778 780 779 781 <script>explorer.outline.writeEnabled = true;</script> 780 782 <dt><span class="decl"> ................................................................................ 801 803 <script>explorer.outline.decSymbolLevel();</script> 802 804 803 805 804 806 </td></tr> 805 807 <tr><td id="docfooter"> 806 808 Page was generated with 807 809 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 808 - on Wed Nov 24 21:12:48 2010 810 + on Thu Nov 25 12:30:12 2010 809 811 810 812 </td></tr> 811 813 </table> 812 814 </div> 813 815 <script> 814 816 explorer.packageExplorer.addModule("index"); 815 817 explorer.packageExplorer.addModule("main");
Modified doc/layer.html from [53e06d787604d0ed] to [26ac57c2c82a7847].
150 150 <script>explorer.outline.decSymbolLevel();</script> 151 151 152 152 153 153 </td></tr> 154 154 <tr><td id="docfooter"> 155 155 Page was generated with 156 156 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 157 - on Wed Nov 24 21:12:49 2010 157 + on Thu Nov 25 12:13:48 2010 158 158 159 159 </td></tr> 160 160 </table> 161 161 </div> 162 162 <script> 163 163 explorer.packageExplorer.addModule("index"); 164 164 explorer.packageExplorer.addModule("main");
Modified doc/lex.html from [583ce05aaa701505] to [a48f5afeb590d4a5].
307 307 <script>explorer.outline.decSymbolLevel();</script> 308 308 309 309 310 310 </td></tr> 311 311 <tr><td id="docfooter"> 312 312 Page was generated with 313 313 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 314 - on Wed Nov 24 21:12:49 2010 314 + on Thu Nov 25 12:15:05 2010 315 315 316 316 </td></tr> 317 317 </table> 318 318 </div> 319 319 <script> 320 320 explorer.packageExplorer.addModule("index"); 321 321 explorer.packageExplorer.addModule("main");
Modified doc/main.html from [9fdfd4c7d1034144] to [47fac5459c7c889e].
62 62 <script>explorer.outline.decSymbolLevel();</script> 63 63 64 64 65 65 </td></tr> 66 66 <tr><td id="docfooter"> 67 67 Page was generated with 68 68 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 69 - on Wed Nov 24 21:12:49 2010 69 + on Thu Nov 25 12:15:04 2010 70 70 71 71 </td></tr> 72 72 </table> 73 73 </div> 74 74 <script> 75 75 explorer.packageExplorer.addModule("index"); 76 76 explorer.packageExplorer.addModule("main");
Modified doc/parse.html from [0556ccaeaa174e09] to [bff389c3a8da9e67].
56 56 <script>explorer.outline.decSymbolLevel();</script> 57 57 58 58 59 59 </td></tr> 60 60 <tr><td id="docfooter"> 61 61 Page was generated with 62 62 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 63 - on Wed Nov 24 21:12:49 2010 63 + on Thu Nov 25 12:15:05 2010 64 64 65 65 </td></tr> 66 66 </table> 67 67 </div> 68 68 <script> 69 69 explorer.packageExplorer.addModule("index"); 70 70 explorer.packageExplorer.addModule("main");
Modified doc/repl.html from [712f2862bf0c7df9] to [bbc57ada8c3877f2].
156 156 <script>explorer.outline.decSymbolLevel();</script> 157 157 158 158 159 159 </td></tr> 160 160 <tr><td id="docfooter"> 161 161 Page was generated with 162 162 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 163 - on Wed Nov 24 21:12:49 2010 163 + on Thu Nov 25 12:15:06 2010 164 164 165 165 </td></tr> 166 166 </table> 167 167 </div> 168 168 <script> 169 169 explorer.packageExplorer.addModule("index"); 170 170 explorer.packageExplorer.addModule("main");
Modified doc/runtime.html from [35487d5e4b345dff] to [c03951e325eae3e8].
42 42 <script>explorer.outline.decSymbolLevel();</script> 43 43 44 44 45 45 </td></tr> 46 46 <tr><td id="docfooter"> 47 47 Page was generated with 48 48 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 49 - on Wed Nov 24 21:12:49 2010 49 + on Thu Nov 25 12:30:12 2010 50 50 51 51 </td></tr> 52 52 </table> 53 53 </div> 54 54 <script> 55 55 explorer.packageExplorer.addModule("index"); 56 56 explorer.packageExplorer.addModule("main");
Modified doc/test.html from [aa27a0b83e9de985] to [3cf05b87d24962dc].
90 90 <script>explorer.outline.addDecl('assert_lt');</script> 91 91 92 92 ; 93 93 </span></dt> 94 94 <script>explorer.outline.writeEnabled = false;</script> 95 95 96 96 97 -<dd>asserts two operands are <<br><br> 97 +<dd>asserts two operands are <<br><br> 98 98 99 99 </dd> 100 100 101 101 <script>explorer.outline.writeEnabled = true;</script> 102 102 <dt><span class="decl">alias 103 103 <span class="currsymbol">assert_le</span> 104 104 <script>explorer.outline.addDecl('assert_le');</script> ................................................................................ 143 143 <script>explorer.outline.decSymbolLevel();</script> 144 144 145 145 146 146 </td></tr> 147 147 <tr><td id="docfooter"> 148 148 Page was generated with 149 149 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 150 - on Wed Nov 24 21:12:49 2010 150 + on Thu Nov 25 12:15:08 2010 151 151 152 152 </td></tr> 153 153 </table> 154 154 </div> 155 155 <script> 156 156 explorer.packageExplorer.addModule("index"); 157 157 explorer.packageExplorer.addModule("main");
Modified doc/tricks.html from [7c435a81bebd30e5] to [67d9668f00ab5789].
91 91 <span class="currsymbol">SimpleToHash</span> 92 92 <script>explorer.outline.addDecl('SimpleToHash');</script> 93 93 94 94 ()</span></dt> 95 95 <script>explorer.outline.writeEnabled = false;</script> 96 96 97 97 98 -<dd>Mixing-in the MOST-DERIVED-member-wise comparator for a class<br><br> 98 +<dd>Mixing-in the MOST-DERIVED-member-wise comparator for a class 99 + BE SURE THAT THIS IS CONSISTENT WITH opCmp and opEquals<br><br> 99 100 100 101 101 102 <script>explorer.outline.incSymbolLevel();</script> 102 103 <dl> 103 104 <script>explorer.outline.writeEnabled = true;</script> 104 105 <dt><span class="decl">const hash_t 105 106 <span class="currsymbol">toHash</span> ................................................................................ 117 118 <script>explorer.outline.decSymbolLevel();</script> 118 119 119 120 120 121 </dd> 121 122 122 123 <script>explorer.outline.writeEnabled = true;</script> 123 124 <dt><span class="decl">template 124 -<span class="currsymbol">SimpleCompare</span> 125 -<script>explorer.outline.addDecl('SimpleCompare');</script> 125 +<span class="currsymbol">SimpleCompareWithoutToHash</span> 126 +<script>explorer.outline.addDecl('SimpleCompareWithoutToHash');</script> 126 127 127 128 ()</span></dt> 128 129 <script>explorer.outline.writeEnabled = false;</script> 129 130 130 131 131 132 <dd>Mixing-in the MOST-DERIVED-member-wise comparator for a class<br><br> 132 133 ................................................................................ 134 135 <script>explorer.outline.incSymbolLevel();</script> 135 136 <dl> 136 137 <script>explorer.outline.writeEnabled = true;</script> 137 138 <dt><span class="decl">const bool 138 139 <span class="currsymbol">opEquals</span> 139 140 <script>explorer.outline.addDecl('opEquals');</script> 140 141 141 -(Object <span class="funcparam">rhs_</span>); 142 +(Object <span class="funcparam">rhs</span>); 142 143 </span></dt> 143 144 <script>explorer.outline.writeEnabled = false;</script> 144 145 145 146 146 147 <dd>member-by-member equality<br><br> 147 148 148 149 </dd> ................................................................................ 160 161 <dd>member-by-member compare<br><br> 161 162 162 163 </dd> 163 164 </dl> 164 165 <script>explorer.outline.decSymbolLevel();</script> 165 166 166 167 168 +</dd> 169 + 170 +<script>explorer.outline.writeEnabled = true;</script> 171 +<dt><span class="decl">template 172 +<span class="currsymbol">SimpleCompare</span> 173 +<script>explorer.outline.addDecl('SimpleCompare');</script> 174 + 175 +()</span></dt> 176 +<script>explorer.outline.writeEnabled = false;</script> 177 + 178 + 179 +<dd>Mixing-in the MOST-DERIVED-member-wise comparator for a class<br><br> 180 + 167 181 </dd> 168 182 169 183 <script>explorer.outline.writeEnabled = true;</script> 170 184 <dt><span class="decl">template 171 185 <span class="currsymbol">SimpleToString</span> 172 186 <script>explorer.outline.addDecl('SimpleToString');</script> 173 187 ................................................................................ 221 235 <span class="currsymbol">firstParam</span> 222 236 <script>explorer.outline.addDecl('firstParam');</script> 223 237 224 238 (T)</span></dt> 225 239 <script>explorer.outline.writeEnabled = false;</script> 226 240 227 241 228 -<dd>Will be used for dynamic overload resolution pattern<br><br> 242 +<dd>Utility<br><br> 229 243 230 244 </dd> 231 245 </dl> 232 246 <script>explorer.outline.decSymbolLevel();</script> 233 247 234 248 235 249 </td></tr> 236 250 <tr><td id="docfooter"> 237 251 Page was generated with 238 252 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 239 - on Wed Nov 24 21:12:49 2010 253 + on Thu Nov 25 12:15:09 2010 240 254 241 255 </td></tr> 242 256 </table> 243 257 </div> 244 258 <script> 245 259 explorer.packageExplorer.addModule("index"); 246 260 explorer.packageExplorer.addModule("main");
Modified doc/value.html from [34785dddb366db48] to [c36eaebf49fd7834].
104 104 <dd>Context (variable environment) 105 105 Simlar to prototype chain of ECMAScript etc. 106 106 But extended with the notion of "Layer"<br><br> 107 107 108 108 109 109 <script>explorer.outline.incSymbolLevel();</script> 110 110 <dl> 111 +<script>explorer.outline.writeEnabled = true;</script> 112 +<dt><span class="decl">void 113 +<span class="currsymbol">set</span> 114 +<script>explorer.outline.addDecl('set');</script> 115 + 116 +(string <span class="funcparam">i</span>, Layer <span class="funcparam">lay</span>, Value <span class="funcparam">v</span>); 117 +</span></dt> 118 +<script>explorer.outline.writeEnabled = false;</script> 119 + 120 + 121 +<dd>Set the value <span class="funcparam">v</span> to the index <span class="funcparam">i</span> of layer <span class="funcparam">lay</span><br><br> 122 + 123 +</dd> 124 + 125 +<script>explorer.outline.writeEnabled = true;</script> 126 +<dt><span class="decl">const bool 127 +<span class="currsymbol">has</span> 128 +<script>explorer.outline.addDecl('has');</script> 129 + 130 +(string <span class="funcparam">i</span>, Layer <span class="funcparam">lay</span>); 131 +</span></dt> 132 +<script>explorer.outline.writeEnabled = false;</script> 133 + 134 + 135 +<dd>True if index <span class="funcparam">i</span> 136 +<span class="currsymbol">has</span> 137 +<script>explorer.outline.addDecl('has');</script> 138 + 139 + value in layer <span class="funcparam">lay</span><br><br> 140 + 141 +</dd> 142 + 143 +<script>explorer.outline.writeEnabled = true;</script> 144 +<dt><span class="decl">Value 145 +<span class="currsymbol">get</span> 146 +<script>explorer.outline.addDecl('get');</script> 147 + 148 +(string <span class="funcparam">i</span>, Layer <span class="funcparam">lay</span>, LexPosition <span class="funcparam">pos</span> = null); 149 +</span></dt> 150 +<script>explorer.outline.writeEnabled = false;</script> 151 + 152 + 153 +<dd>Return the value of index <span class="funcparam">i</span> at layer <span class="funcparam">lay</span>. Throws if it is not set<br><br> 154 + 155 +</dd> 156 + 157 +<script>explorer.outline.writeEnabled = true;</script> 158 +<dt><span class="decl">T 159 +<span class="currsymbol">access</span> 160 +<script>explorer.outline.addDecl('access');</script> 161 + 162 +(T, S...)(Layer <span class="funcparam">lay</span>, string <span class="funcparam">path</span>, S <span class="funcparam">rest</span>); 163 +</span></dt> 164 +<script>explorer.outline.writeEnabled = false;</script> 165 + 166 + 167 +<dd>t. 168 +<span class="currsymbol">access</span> 169 +<script>explorer.outline.addDecl('access');</script> 170 + 171 +!T(lay,a,b,...) returns t.get(a,lay).get(b,lay).... if exists 172 + and has type T. Returns <b>null</b> otherwise<br><br> 173 + 174 +</dd> 175 + 111 176 <script>explorer.outline.writeEnabled = true;</script> 112 177 <dt><span class="decl">bool 113 178 <span class="currsymbol">empty</span> 114 179 <script>explorer.outline.addDecl('empty');</script> 115 180 116 181 (); 117 182 </span></dt> ................................................................................ 148 213 (); 149 214 </span></dt> 150 215 <script>explorer.outline.writeEnabled = false;</script> 151 216 152 217 153 218 <dd>Regard table as a cons-list and convert to an array<br><br> 154 219 220 +</dd> 221 + 222 +<script>explorer.outline.writeEnabled = true;</script> 223 +<dt><span class="decl">Tuple!(string,string,Value)[] 224 +<span class="currsymbol">direct_entries</span> 225 +<script>explorer.outline.addDecl('direct_entries');</script> 226 + 227 +(); 228 +</span></dt> 229 +<script>explorer.outline.writeEnabled = false;</script> 230 + 231 + 232 +<dd>Get the list of direct entries ignoring prototypes in sorted order<br><br> 233 + 234 +</dd> 235 + 236 +<script>explorer.outline.writeEnabled = true;</script> 237 +<dt><span class="decl">Tuple!(string,string,Value)[] 238 +<span class="currsymbol">entries</span> 239 +<script>explorer.outline.addDecl('entries');</script> 240 + 241 +(); 242 +</span></dt> 243 +<script>explorer.outline.writeEnabled = false;</script> 244 + 245 + 246 +<dd>Get the whole list of observable 247 +<span class="currsymbol">entries</span> 248 +<script>explorer.outline.addDecl('entries');</script> 249 + 250 + in unspecified order<br><br> 251 + 155 252 </dd> 156 253 </dl> 157 254 <script>explorer.outline.decSymbolLevel();</script> 158 255 159 256 160 257 </dd> 161 258 </dl> ................................................................................ 162 259 <script>explorer.outline.decSymbolLevel();</script> 163 260 164 261 165 262 </td></tr> 166 263 <tr><td id="docfooter"> 167 264 Page was generated with 168 265 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 169 - on Wed Nov 24 21:12:49 2010 266 + on Thu Nov 25 12:15:07 2010 170 267 171 268 </td></tr> 172 269 </table> 173 270 </div> 174 271 <script> 175 272 explorer.packageExplorer.addModule("index"); 176 273 explorer.packageExplorer.addModule("main");
Modified doc/valueconv.html from [21597c550ad00a0c] to [86d592872cc32a6a].
84 84 <script>explorer.outline.decSymbolLevel();</script> 85 85 86 86 87 87 </td></tr> 88 88 <tr><td id="docfooter"> 89 89 Page was generated with 90 90 <img src="candydoc/img/candydoc.gif" style="vertical-align:middle; position:relative; top:-1px"> 91 - on Wed Nov 24 21:12:49 2010 91 + on Thu Nov 25 12:15:47 2010 92 92 93 93 </td></tr> 94 94 </table> 95 95 </div> 96 96 <script> 97 97 explorer.packageExplorer.addModule("index"); 98 98 explorer.packageExplorer.addModule("main");
Modified index.dd from [d00c8d535d50e1e2] to [caf492581281c25d].
597 597 整数演算の種類が少ないのは、D 言語の std.bigint がビット演算などをサポートしてないためです。 598 598 文字列が結合しかできないのは、単に手抜きです。 599 599 </p> 600 600 )) 601 601 602 602 $(SECTION 外部とのやりとり, $(SECBODY 603 603 $(TABLE 604 - $(TR $(TH print) $(TD (a)) $(TD a を文字列化標準出力に改行付きで表示)) 604 + $(TR $(TH print) $(TD (a)) $(TD a を文字列化標準出力に改行付きで表示して、a を返す)) 605 605 $(TR $(TH argv) $(TD ) $(TD スクリプトに渡された引数文字列のconsリスト)) 606 606 $(TR $(TH gensym) $(TD ()) $(TD エセgensym。変数名として他とかぶらなそうな文字列を返します)) 607 607 $(TR $(TH rand) $(TD (n)) $(TD 0 以上 n 未満の自然数を31bit以内でランダムに生成します)) 608 608 ) 609 609 )) 610 610 <br /> 611 611
Modified polemy/runtime.d from [6911dbe256744186] to [f71ff7dc6628e423].
78 78 t2.set(s.data, ValueLayer, v); 79 79 return t2; 80 80 }); 81 81 e.addPrimitive("{}", ValueLayer, (){ 82 82 return new Table; 83 83 }); 84 84 // IO and others 85 - e.addPrimitive("print", ValueLayer, (Value a){ writeln(a); return new IntValue(0); }); 85 + e.addPrimitive("print", ValueLayer, (Value a){ writeln(a); return a; }); 86 86 e.addPrimitive("gensym", ValueLayer, (){ return new StrValue(freshVarName()); }); 87 87 auto rand = Mt19937(unpredictableSeed); 88 88 e.addPrimitive("rand", ValueLayer, (IntValue n){ 89 89 return new IntValue( uniform(0,cast(int)n.data.toInt(),rand) ); 90 90 }); 91 91 }
Modified readme.txt from [50a2d18cbf87ea26] to [d03287608e84fd60].
1 1 ----------------------------------------------------------------------------- 2 2 Polemy 0.1.0 3 3 by k.inaba (www.kmonos.net) 4 - Nov 24, 2010 4 + Nov 25, 2010 5 5 ----------------------------------------------------------------------------- 6 6 7 7 [How to Build] 8 8 9 9 - Install DMD 10 10 http://www.digitalmars.com/d/2.0/changelog.html 11 11 Version 2.050 is recommended. Older or newer version may not work. 12 12 13 13 - Build 14 - (for Windows) Run build.bat 15 - (for Unix) Run sh build.sh 16 - or use your favorite build tools upon main.d and polemy/*.d. 14 + Run 15 + (on Windows) build.bat 16 + (on Unix) make 17 + or use your favorite build tools upon "main.d polemy/*.d tricks/*.d". 17 18 18 19 Then you will get the executable "polemy" in the "bin" directory. 19 20 20 21 21 22 22 23 [License] 23 24
Deleted sample/ast.pmy version [7e23af883e94d990]
1 -def reverse(lst, acc) 2 -{ 3 - case(lst) 4 - when {car:a, cdr: d}: reverse(d, {car:a, cdr:acc}) 5 - when {}: acc 6 -}; 7 - 8 -@macro reverseArgs(e) {@value( 9 - var ev = @macro(e); 10 - case(ev) 11 - when {is:"App", fun:f, args:a}: 12 - ( 13 - ev {args: reverse(a, {})} 14 -# {is:"App", fun:f, args:reverse(a, {})} 15 - ) 16 - when _ : 17 - ( 18 - ev 19 - ) 20 -)}; 21 - 22 -def main() 23 -{ 24 - print( reverseArgs(1 + 2) ); 25 - print( reverseArgs(1 - 2) ); 26 -}; 27 - 28 -main()
Modified sample/macro.pmy from [b31646ec7576a8a6] to [996468a22f9d9a8e].
1 -@macro twice = fun(x) { x; x }; 2 -@macro max(x,y) { 3 - var _x = x; # no hygenic macro btw.... 4 - var _y = y; # no hygenic macro btw.... 5 - if(_x<_y)then _y else _x 6 -}; 7 -def maxNormal(x,y) { 8 - if(x<y) 9 - then: y 10 - else: x 11 -}; 1 +######################################## 2 +print("----------"); 3 + 4 +@macro twice = fun(x) { x; x }; # Hello Hello 5 +twice( print("Hello") ); 6 + 7 +######################################## 8 +print("----------"); 9 + 12 10 @macro maxBad(x,y) { 13 - if x<y: y else: x 11 + if x<y then y else x 12 +}; 13 +@macro maxGood(x,y) { 14 + var _x = x; # NOTE: no hygenic macro 15 + var _y = y; 16 + if _x < _y then _y else _x 14 17 }; 15 - 16 -@macro LetItBe(x, y) { let it = x in y }; 17 - 18 -@macro pow10(x) { 19 - @value( 20 - def pow(y, n) { 21 - if( n == 1 ) then y 22 - else 23 - @macro( @value(y) * @value(pow(y,n-1)) ) 24 - } 25 - in 26 - pow(@macro(x+1),10) 27 - ) 18 +def maxFun(x,y) { 19 + if x<y then y else x 28 20 }; 21 +@macro maxGreat(x,y){@value( 22 + var nx = gensym(); # generate fresh symbol 23 + var ny = gensym(); 24 + @macro _x = @macro(nx) {name: nx}; # cheating to create {is:"Var" .. } 25 + @macro _y = @macro(ny) {name: ny}; # at macro layer 26 + {is: "Let", name: nx, layer: "", init: @macro(x), expr: 27 + {is: "Let", name: ny, layer: "", init: @macro(y), expr: 28 + @macro(if _x < _y then _y else _x)}} # the expression 29 +)}; 29 30 30 -@macro pow10Hard(x) { 31 - @value( 32 - def pow(x, n) { 33 - if( n == 1 ) then x 34 - else 35 - @macro( @value(x) * @value(pow(x,n-1)) ) 36 - } 37 - in 38 - pow(@macro(x+1),10) 39 - ) 31 +print( maxGood(print(1), print(2)) ); # 1 2 2 32 +print( maxBad(print(1), print(2)) ); # 1 2 2 2 33 +print( maxFun(print(1), print(2)) ); # 1 2 2 34 +print( maxGreat(print(1), print(2)) ); # 1 2 2 35 +print( maxGreat(print(2), print(1)) ); # 2 1 2 36 + 37 +######################################## 38 +print("----------"); 39 + 40 +# the variable "it" is inserted to the scope 41 +@macro LetItBe(x, y) { let it = x in y }; 42 +print( LetItBe("myself", "when I find " ~ it ~ " in times of trouble") ); 43 + 44 +######################################## 45 +print("----------"); 46 + 47 +# layerd parameter can also be used for @macro 48 +# you can mix @macro and normal parameters!! 49 +def 3way(n, c1 @macro, c2 @macro, c3 @macro) 50 +{ 51 + case n*n 52 + when 0: c1 53 + when 1: c2 54 + when 4: c3 40 55 }; 41 56 42 -def printAndReturn(x) 43 -{ 44 - print(x); 45 - x 46 -}; 57 +3way( rand(3), print("One"), print("Two"), print("Three") ); 58 +3way( rand(3), print("One"), print("Two"), print("Three") ); 59 +3way( rand(3), print("One"), print("Two"), print("Three") ); 60 + 61 +######################################## 62 +print("----------"); 63 + 64 +# Conversely, we can mix @value parameter in the macro definition 65 +@macro times(n @value, e) { @value( 66 + if n == 1 then 67 + @macro(e) 68 + else 69 + @macro(e; times(n-1,e)) 70 +)}; 71 +times(7, print("Ichimen no Nanohana")); 72 + 73 +# Here, n is bound to the integer 7, not the AST of it. 74 + 75 +######################################## 76 +print("----------"); 77 + 78 +# Explicit manipulation of AST. 79 +# Reverse the order of arguments of the function call expression 80 +@macro reverseArgs(e) {@value( 81 + def rev(xs, acc) { 82 + case xs when {car:x, cdr:xs}: rev(xs, {car:x, cdr:acc}) when {}: acc 83 + }; 84 + case @macro(e) 85 + when {is:"App", fun:f, args:as}: {is:"App", fun:f, args:rev(as,{})} 86 + when e : e 87 +)}; 88 +print( reverseArgs(1+2) ); # 2+1 == 3 89 +print( reverseArgs(1-2) ); # 2-1 == 1 90 + 91 +######################################## 92 +print("----------"); 93 + 94 +# Both prints "original". Macro respects the neutral layer's "let y=" 95 +# and "fun(y)". It does not alter the inner scope y 96 +@macro test1(y) { fun(y){y}("original") }; 97 +@macro test2(y) { let y = "original" in y }; 98 +print( test1("replaced?") ); 99 +print( test2("replaced?") ); 100 + 101 +######################################## 102 +print("----------"); 103 + 104 +# Macro expansion is done only at the first call. 105 +# So by using @macro parameter, it can remember the argument 106 +# of the first call. 107 +def remember1( x @macro, y ) { if x == y then "yes" else "no" }; 108 +print( remember1(1, 1) ); # yes 1 == 1 109 +print( remember1(2,1) ); # yes "1" == 1 110 +print( remember1(2,2) ); # no "1" != 2 111 + 112 +# exactly the same function, but called in different order 113 +def remember2( x @macro, y ) { if x == y then "yes" else "no" }; 114 +print( remember2(2, 2) ); # yes "2" == 2 115 +print( remember2(2, 1) ); # no "2" != 1 116 +print( remember2(1, 1) ); # no "2" != 1 117 + 118 +# Is this a good thing or a bad thing?? 47 119 48 -def main() 49 -{ 50 - twice( print("foo") ); 51 - print("--------------"); 52 - print(max(printAndReturn(100),printAndReturn(200))); 53 - print("--------------"); 54 - print(maxNormal(printAndReturn(100),printAndReturn(200))); 55 - print("--------------"); 56 - print(maxBad(printAndReturn(100),printAndReturn(200))); 57 - print("--------------"); 58 - print( LetItBe( 1+2+3, it*it ) ); 59 - print("--------------"); 60 - print(pow10(1)); 61 - print(pow10(2)); 62 - print("--------------"); 63 - print(pow10Hard(1)); 64 - print(pow10Hard(2)); 65 -}; 120 +######################################## 121 +print("----------"); 66 122 67 -main(); 123 +# Trick to extract the AST of a function 124 +def foo(x) { x + x }; 125 +print( @macro(@value(foo)(arg1)) ); # prints AST for "arg1 + arg1" 68 126 69 -@macro foo(y) 70 -{ 71 - fun(y){y}(300) 72 -# let y = 300 in y 73 -}; 74 - 75 -print("--------------"); 76 -print(foo(200)); 127 +# If we wrote @macro(foo(arg1)), it is the AST of "foo(arg1)" 128 +# Here, by @value(foo) we obtain the "usual" behavior of foo, 129 +# not the macro-like bahavior to construct AST "foo(??)". 130 +# But still, by @macro( ... ) layer, the "usual" function is run in 131 +# macro mode.