Code Monkey home page Code Monkey logo

Comments (2)

dkvasnicka avatar dkvasnicka commented on September 28, 2024 1

You're probably right. Even I actually ended up not using destructuring at all in the place I originally wanted to use this :)
Appreciate the example though. Thanks!

from rutils.

vseloved avatar vseloved commented on September 28, 2024

Yes, that is correct. I have almost never seen array destructuring in practical use.
However, it can be implemented by the user. For example, like this:

RTL-USER> (defmethod bind-dispatch ((arg1 array) arg2 &rest args)
            (declare (ignore args))
            (let ((garg2 (gensym)))
              `(let* ((,garg2 ,arg2)
                      ,@(mapindex (lambda (i arg) `(,arg (aref ,garg2 ,i)))
                                  (coerce arg1 'list))))))
WARNING:
   redefining BIND-DISPATCH (#<BUILT-IN-CLASS COMMON-LISP:ARRAY>
                             #<SB-PCL:SYSTEM-CLASS COMMON-LISP:T>) in DEFMETHOD
#<STANDARD-METHOD RUTILS.BIND:BIND-DISPATCH (ARRAY T) {10178E61A3}>
RTL-USER> (m1 '(with ((#(a b) #(1 2 3)))
            b))
(LET* ((#:G716 #(1 2 3)) (A (AREF #:G716 0)) (B (AREF #:G716 1)))
  B)
T
RTL-USER> (with ((#(a b) #(1 2 3)))
            b)
; in: WITH ((#(A B) #(1 2 3)))
;     (LET* ((#:G717 #(1 2 3))
;            (RTL-USER::A (AREF #:G717 0))
;            (RTL-USER::B (AREF #:G717 1)))
;       RTL-USER::B)
; 
; caught STYLE-WARNING:
;   The variable A is defined but never used.
; 
; compilation unit finished
;   caught 1 STYLE-WARNING condition
2

from rutils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.