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

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: