summary refs log tree commit diff stats
path: root/tests/array/tarray.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/array/tarray.nim')
-rw-r--r--tests/array/tarray.nim10
1 files changed, 5 insertions, 5 deletions
diff --git a/tests/array/tarray.nim b/tests/array/tarray.nim
index eadb53ac1..81a43f203 100644
--- a/tests/array/tarray.nim
+++ b/tests/array/tarray.nim
@@ -344,11 +344,11 @@ block troofregression:
     if $a != b:
       echo "Failure ", a, " != ", b
 
-  check type(4 ...< 1), "HSlice[system.int, system.int]"
-  check type(4 ...< ^1), "HSlice[system.int, system.BackwardsIndex]"
-  check type(4 ... pred(^1)), "HSlice[system.int, system.BackwardsIndex]"
-  check type(4 ... mypred(8)), "HSlice[system.int, system.int]"
-  check type(4 ... mypred(^1)), "HSlice[system.int, system.BackwardsIndex]"
+  check typeof(4 ...< 1), "HSlice[system.int, system.int]"
+  check typeof(4 ...< ^1), "HSlice[system.int, system.BackwardsIndex]"
+  check typeof(4 ... pred(^1)), "HSlice[system.int, system.BackwardsIndex]"
+  check typeof(4 ... mypred(8)), "HSlice[system.int, system.int]"
+  check typeof(4 ... mypred(^1)), "HSlice[system.int, system.BackwardsIndex]"
 
   var rot = 8
 
xes; plus a big Windows lib update' href='/ahoang/Nim/commit/doc/effects.txt?h=devel&id=286e5958d662038fdc852861ecd07c89256495ab'>286e5958d ^
053309e60 ^




286e5958d ^
053309e60 ^





286e5958d ^
053309e60 ^

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
                                                                     
                                  








                                                                     
                                                                


                                                                  
                   





                                                                          
                                                     

 
                                                   




               
                                                                         





                                                                             
                                                      

 
=====================================================================
               Side effects in Nim
=====================================================================

Note: Side effects are implicit produced values! Maybe they should be
explicit like in Haskell?


The idea is that side effects and partial evaluation belong together:
Iff a proc is side effect free and all its argument are evaluable at
compile time, it can be evaluated by the compiler. However, really
difficult is the ``newString`` proc: If it is simply wrapped, it
should not be evaluated at compile time! On other occasions it can
and should be evaluted:

.. code-block:: nim
  proc toUpper(s: string): string =
    result = newString(len(s))
    for i in 0..len(s) - 1:
      result[i] = toUpper(s[i])

No, it really can always be evaluated. The code generator should transform
``s = "\0\0\0..."`` back into ``s = newString(...)``.


``new`` cannot be evaluated at compile time either.


Raise statement
===============

It is impractical to consider ``raise`` as a statement with side effects.


Solution
========

Being side effect free does not suffice for compile time evaluation. However,
the evaluator can attempt to evaluate at compile time.