Received: by 10.140.82.35 with SMTP id f35mr5785977rvb.10.1199462391924; Fri, 04 Jan 2008 07:59:51 -0800 (PST) Return-Path: Received: from mu-out-0910.google.com (mu-out-0910.google.com [209.85.134.190]) by mx.google.com with ESMTP id h71si19643080nzf.3.2008.01.04.07.59.50; Fri, 04 Jan 2008 07:59:51 -0800 (PST) Received-SPF: pass (google.com: domain of toralf.witt...@gmail.com designates 209.85.134.190 as permitted sender) client-ip=209.85.134.190; Authentication-Results: mx.google.com; spf=pass (google.com: domain of toralf.witt...@gmail.com designates 209.85.134.190 as permitted sender) smtp.mail=toralf.witt...@gmail.com; dkim=pass (test mode) header...@gmail.com Received: by mu-out-0910.google.com with SMTP id w8so4476172mue.4 for ; Fri, 04 Jan 2008 07:59:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:subject:from:to:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer; bh=UIgVfqB955pKVFaZ74pYDW95y+t2VIvmAsjC1h3xCxs=; b=K4o8yHFZSEbh23PJyoYKcMGkOlsz+Og8qbomAPrmloZz9BVuJ2JmUNxpr1W/UpwJpbTKzfJ+8KMCwaKz9n2T9lP20eszCiQNJgtCT/mAi0AxNie9KGkNBdkktaFt816mKx7KJo4d2aTvhLfTeuqG/MLF1uk3wkGAlK+Pnq4NT+s= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:from:to:in-reply-to:references:content-type:date:message-id:mime-version:x-mailer; b=vZG9dmiU0ZJMu/50851XxfT36M019r8ZPDECAvps05F+zGLjPjfaOD+Yl3sKWF44NQwlBCTipsEFUsenuZaaoiBwwJIeDbOiwkwJ/gF1XYd2LGQLzYjjmpxoozx4SGM3nstjW6PAW8PRrA+GofuNRLuiyC8zmx8TkxYEpgsC/gQ= Received: by 10.78.122.16 with SMTP id u16mr19903613huc.28.1199462390340; Fri, 04 Jan 2008 07:59:50 -0800 (PST) Return-Path: Received: from ?192.168.178.20? ( [80.132.22.61]) by mx.google.com with ESMTPS id y6sm50396126mug.1.2008.01.04.07.59.43 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 04 Jan 2008 07:59:44 -0800 (PST) Subject: Re: Creating a PrintWriter: No matching ctor found From: Toralf Wittner To: clojure@googlegroups.com In-Reply-To: References: <01c793a1-adf8-4a40-a145-247935a85...@q77g2000hsh.googlegroups.com> <1199394163.6080.22.camel@laptop-wittner> <892229d1-4d3e-4457-98a9-4cbd36736...@1g2000hsl.googlegroups.com> Content-Type: multipart/mixed; boundary="=-dg75O46xgKfk2a2ADKPJ" Date: Fri, 04 Jan 2008 16:59:42 +0100 Message-Id: <1199462382.6103.24.camel@laptop-wittner> Mime-Version: 1.0 X-Mailer: Evolution 2.12.1 --=-dg75O46xgKfk2a2ADKPJ Content-Type: text/plain Content-Transfer-Encoding: 7bit On Thu, 2008-01-03 at 19:56 -0800, Rich Hickey wrote: > This now works: > > (new PrintWriter (new ByteArrayOutputStream) (boolean :t)) > > Not using your fix, the problem was elsewhere. However the current state with regards to :t seems somewhat inconsistent to me. It is not possible to do (new Boolean :t) but something like (. (new javax.swing.JFrame "Test") (setVisible :t)) is ok, (. Boolean (valueOf :t)) again is not. Also note that (new Boolean nil) throws an exception: user=> (new Boolean nil) clojure.lang.Compiler$CompilerException: REPL:1: null at clojure.lang.Compiler.analyzeSeq(Unknown Source) at clojure.lang.Compiler.analyze(Unknown Source) at clojure.lang.Compiler.analyze(Unknown Source) at clojure.lang.Compiler.eval(Unknown Source) at clojure.lang.Repl.main(Unknown Source) Caused by: java.lang.NullPointerException at java.lang.Class.isAssignableFrom(Native Method) at clojure.lang.Reflector.paramArgTypeMatch(Unknown Source) at clojure.lang.Compiler.getMatchingParams(Unknown Source) at clojure.lang.Compiler$NewExpr.(Unknown Source) at clojure.lang.Compiler$NewExpr$Parser.parse(Unknown Source) ... 5 more I think the patch Chas posted is still valid because you can then use nil or :t without type casts. If the NPE in Reflector.paramArgTypeMatch is fixed, e.g. by putting "if(argType == null) return true;" in the first line (I think this is justified because null is a valid member of every type)) then one can do: user=> (new Boolean :t) true user=> (new Boolean nil) false user=> (. Boolean (valueOf :t)) true user=> (. Boolean (valueOf nil)) nil user=> (new Boolean (boolean :t)) true user=> (new Boolean (boolean nil)) false user=> (. Boolean (valueOf (boolean :t))) true user=> (. Boolean (valueOf (boolean nil))) nil user=> (. (new javax.swing.JFrame "Test") (setVisible :t)) nil user=> (. (new javax.swing.JFrame "Test") (setVisible nil)) nil Cheers, Toralf --=-dg75O46xgKfk2a2ADKPJ Content-Disposition: attachment; filename=bool.diff Content-Type: text/x-patch; name=bool.diff; charset=utf-8 Content-Transfer-Encoding: 7bit Index: src/jvm/clojure/lang/Reflector.java =================================================================== --- src/jvm/clojure/lang/Reflector.java (revision 601) +++ src/jvm/clojure/lang/Reflector.java (working copy) @@ -289,6 +289,8 @@ } static public boolean paramArgTypeMatch(Class paramType, Class argType){ + if(argType == null) + return true; if(paramType == argType || paramType.isAssignableFrom(argType)) return true; if(paramType == int.class) @@ -324,7 +326,7 @@ Class paramType = params[i]; if(paramType == boolean.class) { - ret = arg == null || argType == Boolean.class; + ret = arg == null || argType == Boolean.class || arg == RT.T; } else if(paramType.isPrimitive()) { --=-dg75O46xgKfk2a2ADKPJ--