Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> valid Bel function

What do you mean by this? Can valid functions produce errors? Does a valid function need to halt?

> In the case of global bindings, there is nothing to analyze

A global name will be used in the program text a finite number of times. You can treat each usage as an the creation of a new value and do escape analysis on it. Doing this on all usages of a variable can determine that the none of these values escape and therefore the value cannot be passed to a list mutating function and is safe to optimise.



> What do you mean by this?

Whatever the spec says.

> You can treat each usage as an the creation of a new value

No, you can't, because aliasing.

https://en.wikipedia.org/wiki/Aliasing_(computing)

You really are totally clueless.


That's not an explanation, and quite frankly it's entirely unrelated. You can quite easily guarantee a top-level variable isn't initially aliased by looking at the form that assigned it. In most cases this will be a literal which is a fresh, unaliased value. If the value becomes aliased to more than one name, that means one instance of it escaped, so you will detect that when doing escape analysis. It's really quite simple logic.

> Whatever the spec says.

Well the document does mention a check for validity.

  (def variable? (v)
       (if (atom v)
           (no (literal v))
           (caris v vmark)))
  
  (def valid-special-param? ((t-or-o (o var) (o expr) . rest))
       (and (valid-params? var)
            ;; t parameters must have a type check.
            (or (id t-or-o o) expr)
            (no rest)))
  
  (def valid-params? (p)
       (if (no p) t
           (variable? p) t
           (or (caris p t) (caris p o)) (valid-special-param? p)
           (and (id (type p) 'pair)
                (valid-params? (car p))
                (valid-params? (cdr p)))))
  
  (def valid-top-params? (p)
       (and (no (caris p o)) (valid-params? p)))
  
  (def valid-function? ((o lit) (o clo) (o env) (o params) (o body) . rest)
       (and (id lit 'lit)
            (id clo 'clo)
            ;; Env, a proper list of pairs of symbols and bindings.
            (and (proper env)
                 (all [id (type _) 'pair] env)
                 (all variable? (map car env)))
            (valid-top-params? params)))
I think this should work, but I don't think it's worth $100.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: