Re: [armedbear-devel] SETF for JFEILDS

Does anyone object to adding this to java.lisp? If not could it be done? (defun (setf jfield) (newvalue class-ref-or-field field-or-instance &optional ( instance :noinst) (value :novalue)) (if (eq instance :noinst) (jfield class-ref-or-field field-or-instance newvalue) (jfield class-ref-or-field field-or-instance instance newvalue))) ----- Original Message ----- From: <dmiles@users.sourceforge.net> To: "Armed Bear" <armedbear-devel@common-lisp.net> Sent: Tuesday, November 10, 2009 12:24 AM Subject: SETF for JFEILDS
Hi,
Could we add add something like this to java.lisp?
(defun (setf jfield) (newvalue class-ref-or-field field-or-instance &optional ( instance :noinst) (value :novalue)) (if (eq instance :noinst) (jfield class-ref-or-field field-or-instance newvalue) (jfield class-ref-or-field field-or-instance instance newvalue)))
-Thx

On Mon, Nov 23, 2009 at 2:36 PM, <logicmoo@gmail.com> wrote:
Does anyone object to adding this to java.lisp? If not could it be done?
(defun (setf jfield) (newvalue class-ref-or-field field-or-instance &optional ( instance :noinst) (value :novalue)) (if (eq instance :noinst) (jfield class-ref-or-field field-or-instance newvalue) (jfield class-ref-or-field field-or-instance instance newvalue)))
It seems a nice idea to me, but there are a couple of things that I don't understand: - why :noinst and not simply nil? - value is not used, what's the point of it? A.
----- Original Message ----- From: <dmiles@users.sourceforge.net> To: "Armed Bear" <armedbear-devel@common-lisp.net> Sent: Tuesday, November 10, 2009 12:24 AM Subject: SETF for JFEILDS
Hi,
Could we add add something like this to java.lisp?
(defun (setf jfield) (newvalue class-ref-or-field field-or-instance &optional ( instance :noinst) (value :novalue)) (if (eq instance :noinst) (jfield class-ref-or-field field-or-instance newvalue) (jfield class-ref-or-field field-or-instance instance newvalue)))
-Thx
_______________________________________________ armedbear-devel mailing list armedbear-devel@common-lisp.net http://common-lisp.net/cgi-bin/mailman/listinfo/armedbear-devel

----- Original Message ----- From: "Alessio Stalla" <alessiostalla@gmail.com> To: <dmiles@users.sourceforge.net> Cc: "Armed Bear" <armedbear-devel@common-lisp.net> Sent: Monday, November 23, 2009 5:42 AM Subject: Re: [armedbear-devel] SETF for JFEILDS On Mon, Nov 23, 2009 at 2:36 PM, <logicmoo@gmail.com> wrote:
Does anyone object to adding this to java.lisp? If not could it be done?
(defun (setf jfield) (newvalue class-ref-or-field field-or-instance &optional ( instance :noinst) (value :novalue)) (if (eq instance :noinst) (jfield class-ref-or-field field-or-instance newvalue) (jfield class-ref-or-field field-or-instance instance newvalue)))
It seems a nice idea to me, but there are a couple of things that I don't understand:
A>- why :noinst and not simply nil? JFIELD is defined as: class-ref-or-field field-or-instance &optional instance value The valid argument patterns for this operation are: (class-ref field-name): to retrieve the value of a static field. (class-ref field-name instance-ref): to retrieve the value of a class field of the instance. (class-ref field-name primitive-value:) to store primitive-value in a static field. (class-ref field-name instance-ref value): to store value in a class field of the instance. (class-ref field-name nil value): to store value in a static field (when value may be confused with an instance-ref). (field-name instance): to retrieve the value of a field of the instance. The class is derived from the instance. (field-name instance value): to store value in a field of the instance. The class is derived from the instance. JFIELD doesn't distingusih between static and non static fields Also cases of "class-ref field-name instance-ref value" (accessing superclass field) Depending on how the field is defined (setf (jfield *MyClass* "someStaticBooleanField") NIL) it is distinguable from (setf (jfield *MySuperClass* "nonStaticBooleanField" *my-instance* ) NIL) -------------------------------------------------------------------------------------------------------------------------- A>- value is not used, what's the point of it? correct the "default :novalue" is not needed. (I was debugging and trying to find corner cases with all those bizzare legal jfield signatures ) but... "value" as an &optional was needed to match the signature of what is legal for jfield so things like this can work: (define-symbol-macro %iscold (jfield "org.armedbear.lisp.Lisp" "cold")) %iscold ;; ==> NIL (setq %iscold T) ;; ==> T %iscold ;; ==> T (setq %iscold NIL) ;; ==> NIL

These 3 look good CL-USER(2): (jclass-of (jfield "java.lang.System" "out")) "java.io.PrintStream" "java.io.PrintStream" CL-USER(4): (jclass-of 1) NIL NIL CL-USER(5): (jclass-of (make-immediate-object 1)) "java.lang.Integer" "java.lang.Integer" But is this correct? CL-USER(17): (jclass-of (jfield "java.lang.Boolean" "TRUE")) NIL NIL CL-USER(18): (jclass-of (jfield "java.lang.Boolean" "FALSE")) NIL NIL
participants (2)
-
Alessio Stalla
-
logicmoo@gmail.com