| 1 | = Quickbok 1.5 = |
| 2 | |
| 3 | == Dynamic Scoping vs. Static Scoping == |
| 4 | |
| 5 | {{{ |
| 6 | }}} |
| 7 | |
| 8 | quickbook currently uses dynamic scoping which is generally |
| 9 | accepted to be a bad idea. So I'd like to change it to use static |
| 10 | scoping. |
| 11 | |
| 12 | {{{ |
| 13 | [template x static scoping] |
| 14 | [template foo1[] [x]] |
| 15 | [template foo2[x] [foo1]] |
| 16 | [foo2 dynamic scoping] |
| 17 | }}} |
| 18 | |
| 19 | Will currently return 'dynamic scoping', I'd like it to change it to |
| 20 | return 'static scoping' for 1.5 or whatever. |
| 21 | |
| 22 | == Template Lookup Location == |
| 23 | |
| 24 | #2034 |
| 25 | |
| 26 | When template arguments are expanded they are evaluated with the |
| 27 | current scope rather than the scope they were called with which can be |
| 28 | surprising. So I'd like to change it so that they are bound to the |
| 29 | correct scope. |
| 30 | |
| 31 | {{{ |
| 32 | [template x new] |
| 33 | [template foo1[a x] [a]] |
| 34 | [foo1 [x] old] |
| 35 | }}} |
| 36 | |
| 37 | Will return 'old' at the moment, I'd prefer it to return 'new'. |
| 38 | Another way to achieve this would be to evaluate template arguments |
| 39 | eagerly but that would be a much bigger change and harder to implement |
| 40 | a version switch for. |
| 41 | |
| 42 | == Simplified Template Arg Handling == |
| 43 | |
| 44 | #1174 |
| 45 | |
| 46 | David Abrahams wrote: |
| 47 | > IMO the rules that allow you to do things like leave out a nullary |
| 48 | > template's argument list when the template body doesn't look like an |
| 49 | > argument list |
| 50 | |
| 51 | Joel: |
| 52 | > This can be removed. I agree. |
| 53 | |
| 54 | David: |
| 55 | > and combining simple argument separators with ".." |
| 56 | > separators are confusing at best and don't provide real utility. I |
| 57 | > think we should avoid such syntax quirks. |
| 58 | |
| 59 | Joel: |
| 60 | > Those are there to provide backward compatibility. One of the goals |
| 61 | > is to replace/rewrite most of the rules using templates. Alas, QB's |
| 62 | > syntax is admittedly quirky to begin with. In an ideal world, I'd |
| 63 | > redesign the syntax set and rewrite Qb, but, I guess I don't quite |
| 64 | > have time to invest on such a rewrite. |
| 65 | |
| 66 | David: |
| 67 | > I also have no problem with |
| 68 | {{{ |
| 69 | [stuff a..b..c..d] |
| 70 | }}} |
| 71 | > I do have a problem with |
| 72 | {{{ |
| 73 | [stuff a..b c d] |
| 74 | }}} |
| 75 | > unless that's just 2 arguments. |
| 76 | |
| 77 | Joel: |
| 78 | > Alright, so you want it either to be the first form, or the |
| 79 | > second form, but not combined. Noted. |
| 80 | |
| 81 | == Spaces in template arguments == |
| 82 | |
| 83 | #2036 |
| 84 | |
| 85 | {{{ |
| 86 | [template join1[a b] [b][a]] [/<- "error: Expanding template"] |
| 87 | [template join2[a b] [a][b]] |
| 88 | [template test[x] [join1 [join2 0 [x]] 0]] |
| 89 | [test 0] |
| 90 | }}} |
| 91 | |
| 92 | The problem here is that join1 is interpreting spaces as argument seperators. So this line: |
| 93 | {{{ |
| 94 | [template test[x] [join1 [join2 0 [x]] 0]] |
| 95 | }}} |
| 96 | is interpreted as: |
| 97 | {{{ |
| 98 | [template test[x] [join1 [join2..0 [x]] 0]] |
| 99 | }}} |
| 100 | Which is confusing, it probably should be interpreted as: |
| 101 | {{{ |
| 102 | [template test[x] [join1 [join2 0 [x]]..0]] |
| 103 | }}} |
| 104 | |
| 105 | I think that both seperators (spaces and `..`) should be ignored inside square brackets. |