my-test-7   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/examples/core/extempore_lang.xtm

Implementation

;; here's another tuple example
;; note that my-test-7's return type is inferred
;; by the tuple-reference index
;; (i.e. i64 being tuple index 0)
(bind-func my-test-7
  (lambda ()
    (let ((a:<i64,double>* (alloc)) ; returns pointer to type <i64,double>
          (b 37)
          (c 6.4))
      (tuple-set! a 0 b) ;; set i64 to 64
      (tset! a 1 c) ;; set double to 6.4 - tset! is an alias for tuple-set!
      (printf "tuple:1 %lld::%f\n" (tuple-ref a 0) (tref a 1))
      ;; we can fill a tuple in a single call by using tfill!
      (tfill! a 77 77.7)
      (printf "tuple:2 %lld::%f\n" (tuple-ref a 0) (tuple-ref a 1))
      (tuple-ref a 0)))) ;; return first element which is i64


Back to Index