X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=abcl-and-lire.post;h=dc84b1f10af04a4ec347989a8db0cd68604ff474;hb=HEAD;hp=fc1814f4fab4548e32eeff316b2b8999633a87d7;hpb=6ded27177beb743bdda0493fe3783a187da4e956;p=blog.git diff --git a/abcl-and-lire.post b/abcl-and-lire.post index fc1814f..dc84b1f 100644 --- a/abcl-and-lire.post +++ b/abcl-and-lire.post @@ -80,7 +80,7 @@ specifies all names: ``` (defun read-image (pathname) - (jstatic "read" "javax.imageio.ImageIO" (jnew "java.io.FileInputStream" (namestring pathname)))) + (jstatic "read" "javax.imageio.ImageIO" (jnew "java.io.File" (namestring pathname)))) ``` Though with a combination of JSS and cached lookup it could be nicer, @@ -88,10 +88,10 @@ even though the setup is more verbose: ``` (defvar +image-io+ (jclass "javax.imageio.ImageIO")) -(defvar +file-input-stream+ (jclass "java.io.FileInputStream")) +(defvar +file+ (jclass "java.io.File")) (defun read-image (pathname) - (#"read" +image-io+ (jnew +file-input-stream+ (namestring pathname)))) + (#"read" +image-io+ (jnew +file+ (namestring pathname)))) ``` At this point without other improvements (auto-coercion of pathnames, @@ -237,6 +237,19 @@ Generally this would be appropriate, except for places where we'd really want the Java side to receive a Lisp object. Having a special variable to *disable* conversion might be enough for these purposes. +If we were to forego the nice properties of JSS by requiring a function +form, the following would be another option: + +``` +(defun read-image (pathname) + $(read 'ImageIO (new 'FileInputStream pathname))) +``` + +Where `$(...)` would be special syntax indicating a Java method call. +Of course the exact syntax is not very relevant, more importantly static +properties could be used to generate a faster, early bound call by +examining the supplied arguments as a limited form of type inference. + ## Summary After introducing the necessary steps to start using ABCL with "native"