<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -106,10 +106,11 @@
   writes the .class file to the *compile-path* directory.  When not
   compiling, does nothing. 
 
-  A constructor will be defined, taking the designated fields followed
-  by a metadata map (nil for none) and an extension field map (nil for
-  none). In the method bodies, the (unqualified) name can be used
-  to name the class (for calls to new etc).
+  Two constructors will be defined, one taking the designated fields
+  followed by a metadata map (nil for none) and an extension field
+  map (nil for none), and one taking only the fields (using nil for
+  meta and extension fields). In the method bodies, the (unqualified)
+  name can be used to name the class (for calls to new etc).
 
   See deftype for a description of fields, methods, equality and
   generated interfaces.&quot;</diff>
      <filename>src/clj/clojure/core_deftype.clj</filename>
    </modified>
    <modified>
      <diff>@@ -2949,6 +2949,7 @@ static public class ObjExpr implements Expr{
 	int line;
 	PersistentVector constants;
 	int constantsID;
+	int altCtorDrops = 0;
 
 	IPersistentVector keywordCallsites;
 
@@ -3231,6 +3232,31 @@ static public class ObjExpr implements Expr{
 
 		ctorgen.endMethod();
 
+		if(altCtorDrops &gt; 0)
+			{
+					//ctor that takes closed-overs and inits base + fields
+			Type[] ctorTypes = ctorTypes();
+			Type[] altCtorTypes = new Type[ctorTypes.length-altCtorDrops];
+			for(int i=0;i&lt;altCtorTypes.length;i++)
+				altCtorTypes[i] = ctorTypes[i];
+			Method alt = new Method(&quot;&lt;init&gt;&quot;, Type.VOID_TYPE, altCtorTypes);
+			ctorgen = new GeneratorAdapter(ACC_PUBLIC,
+															alt,
+															null,
+															null,
+															cv);
+			ctorgen.visitCode();
+			ctorgen.loadThis();
+			ctorgen.loadArgs();
+			for(int i=0;i&lt;altCtorDrops;i++)
+				ctorgen.visitInsn(Opcodes.ACONST_NULL);
+
+			ctorgen.invokeConstructor(objtype, new Method(&quot;&lt;init&gt;&quot;, Type.VOID_TYPE, ctorTypes));
+
+			ctorgen.returnValue();
+			ctorgen.endMethod();
+			}
+
 		emitMethods(cv);
 
 		if(keywordCallsites.count() &gt; 0)
@@ -5401,7 +5427,7 @@ static public class NewInstanceExpr extends ObjExpr{
 	}
 	}
 
-	static Expr build(IPersistentVector interfaceSyms, IPersistentVector fieldSyms, Symbol thisSym, String className,
+	static ObjExpr build(IPersistentVector interfaceSyms, IPersistentVector fieldSyms, Symbol thisSym, String className,
 	                  Symbol typeTag, ISeq methodForms) throws Exception{
 		NewInstanceExpr ret = new NewInstanceExpr(null);
 
@@ -5435,6 +5461,8 @@ static public class NewInstanceExpr extends ObjExpr{
 			//use array map to preserve ctor order
 			ret.closes = new PersistentArrayMap(closesvec);
 			ret.fields = fmap;
+			for(int i=fieldSyms.count()-1;i &gt;= 0 &amp;&amp; ((Symbol)fieldSyms.nth(i)).name.startsWith(&quot;__&quot;);--i)
+				ret.altCtorDrops++;
 			}
 		//todo - set up volatiles
 //		ret.volatiles = PersistentHashSet.create(RT.seq(RT.get(ret.optionsMap, volatileKey)));
@@ -5545,6 +5573,30 @@ static public class NewInstanceExpr extends ObjExpr{
 		ctorgen.returnValue();
 		ctorgen.endMethod();
 
+		if(ret.altCtorDrops &gt; 0)
+			{
+			Type[] ctorTypes = ret.ctorTypes();
+			Type[] altCtorTypes = new Type[ctorTypes.length-ret.altCtorDrops];
+			for(int i=0;i&lt;altCtorTypes.length;i++)
+				altCtorTypes[i] = ctorTypes[i];
+			Method alt = new Method(&quot;&lt;init&gt;&quot;, Type.VOID_TYPE, altCtorTypes);
+			ctorgen = new GeneratorAdapter(ACC_PUBLIC,
+															alt,
+															null,
+															null,
+															cv);
+			ctorgen.visitCode();
+			ctorgen.loadThis();
+			ctorgen.loadArgs();
+			for(int i=0;i&lt;ret.altCtorDrops;i++)
+				ctorgen.visitInsn(Opcodes.ACONST_NULL);
+
+			ctorgen.invokeConstructor(Type.getObjectType(COMPILE_STUB_PREFIX + &quot;/&quot; + ret.internalName),
+			                          new Method(&quot;&lt;init&gt;&quot;, Type.VOID_TYPE, ctorTypes));
+
+			ctorgen.returnValue();
+			ctorgen.endMethod();
+			}
 		//end of class
 		cv.visitEnd();
 </diff>
      <filename>src/jvm/clojure/lang/Compiler.java</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>406fc1c00f8138d47445047c9e17a8af12fefcff</id>
    </parent>
  </parents>
  <author>
    <name>Rich Hickey</name>
    <email>richhickey@gmail.com</email>
  </author>
  <url>http://github.com/richhickey/clojure/commit/7a10c9077b5d037e782b2bc63c821f42337e9e04</url>
  <id>7a10c9077b5d037e782b2bc63c821f42337e9e04</id>
  <committed-date>2009-11-04T09:31:34-08:00</committed-date>
  <authored-date>2009-11-04T09:31:34-08:00</authored-date>
  <message>generate second ctor for defclass/type taking designated fields only, defaulting rest to nil</message>
  <tree>37a2b366a4fc9a08386f802cc674dbad41315312</tree>
  <committer>
    <name>Rich Hickey</name>
    <email>richhickey@gmail.com</email>
  </committer>
</commit>
