<commit_before>;; Copyright (c) 2013-2014 by <NAME>, All Rights Reserved.

(define *namespaces* '())
(define *active-namespaces* (make-table))
(define *declared-imported* '())

(define (push-namespace name)
  (set! *namespaces* (cons (cons (add-parent-namespace-names name) 
                                 (existing-namespace-defs name)) 
                           *namespaces*)))

(define (pop-namespace)
  (if (not (null? *namespaces*))
      (let ((top (car *namespaces*)))
        (table-set! *active-namespaces* (car top) (cdr top))
        (set! *namespaces* (cdr *namespaces*)))))

(define (existing-namespace-defs name)
  (table-ref *active-namespaces* name '()))

(define (add-parent-namespace-names name)
  (if (null? *namespaces*) name
      (let loop ((namespaces (reverse *namespaces*))
                 (sname ""))
        (if (null? namespaces)
            (string->symbol (string-append sname (symbol->string name)))
            (loop (cdr namespaces)
                  (string-append sname (symbol->string (caar namespaces)) "_"))))))

(define (import-from-namespace name #!optional defs prefix)
  (let ((n (find-namespace name)))
    (if (and (not n) (not defs)) (error "namespace not found" name))
    (if (and n defs) (validate-import-names defs n))
    (let loop ((defs (if defs defs n))
               (imports '()))
      (if (null? defs)
          (cons 'begin imports)
          (let ((import-name (get-import-name (car defs) prefix)))
            (loop (cdr defs) (cons `(,(if (in-declared-imports? import-name) 'set! 'define)
                                    ,import-name
                                    ,(get-name-from-namespace (car defs) name))<commit_msg>namespace access made dynamic.<commit_after>;; Copyright (c) 2013-2014 by <NAME>, All Rights Reserved.

(define *namespaces* '())
(define *active-namespaces* (make-table))
(define *declared-imported* '())

(define (push-namespace name)
  (set! *namespaces* (cons (cons (add-parent-namespace-names name) 
                                 (existing-namespace-defs name)) 
                           *namespaces*)))

(define (pop-namespace)
  (if (not (null? *namespaces*))
      (let ((top (car *namespaces*)))
	  (set! *namespaces* (cdr *namespaces*))
	  `(table-set! *active-namespaces* ',(car top) ',(cdr top)))
      #f))

(define (existing-namespace-defs name)
  (table-ref *active-namespaces* name '()))

(define (add-parent-namespace-names name)
  (if (null? *namespaces*) name
      (let loop ((namespaces (reverse *namespaces*))
                 (sname ""))
        (if (null? namespaces)
            (string->symbol (string-append sname (symbol->string name)))
            (loop (cdr namespaces)
                  (string-append sname (symbol->string (caar namespaces)) "_"))))))

(define (import-from-namespace name #!optional defs prefix)
  (let ((n (find-namespace name)))
    (if (and (not n) (not defs)) (error "namespace not found" name))
    (if (and n defs) (validate-import-names defs n))
    (let loop ((defs (if defs defs n))
               (imports '()))
      (if (null? defs)
          (cons 'begin imports)
          (let ((import-name (get-import-name (car defs) prefix)))
            (loop (cdr defs) (cons `(,(if (in-declared-imports? import-name) 'set! 'define)
                                    ,import-name
                                    ,(get-name-from-namespace (car defs) name))
{'fraction_non_alphanumeric': 0.16202754175212422, 'fraction_numerical': 0.004687957808379725, 'mean_word_length': 2.400398406374502, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3285809', 'n_tokens_mistral': 1077, 'n_tokens_neox': 1050, 'n_words': 293}