Hi,

Nim has a wonderful feature of the sideEffect tracking and I know one can 
annotate the proc with noSideEffects pragma to enforce no side effects 
constraint.

In my case proc is not annotated, but I still would like to know whether 
particular function has side effects or not. Mainly to know if it is safe to 
incrementalize the calculation and it includes memoization.
    
    
    proc p1(a, b: int) : int =
      result = 2 * a + b
    
    proc p2(a, b: int) : int =
      echo "AAAA"
      result = b
    
    macro hasSideEffect(proc : typed) : bool =
      ... # not clear how to implement
    
    
    hasSideEffect(p1) # returns compile time false
    hasSideEffect(p2) # returns compile time true
    

Reply via email to