<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -139,6 +139,10 @@ extern &quot;C&quot; {
 
   extern dfsch_object_t* dfsch_make_slot_accessor(dfsch_type_t* type,
                                                   char* slot);
+  extern dfsch_object_t* dfsch_make_slot_reader(dfsch_type_t* type,
+                                                char* slot);
+  extern dfsch_object_t* dfsch_make_slot_writer(dfsch_type_t* type,
+                                                char* slot);
 
 
   /** Is OBJ null? */</diff>
      <filename>dfsch/dfsch.h</filename>
    </modified>
    <modified>
      <diff>@@ -76,6 +76,10 @@ extern dfsch_type_t dfsch_writer_state_type;
 
 extern dfsch_type_t dfsch_slot_accessor_type;
 #define DFSCH_SLOT_ACCESSOR_TYPE (&amp;dfsch_slot_accessor_type)
+extern dfsch_type_t dfsch_slot_reader_type;
+#define DFSCH_SLOT_READER_TYPE (&amp;dfsch_slot_reader_type)
+extern dfsch_type_t dfsch_slot_writer_type;
+#define DFSCH_SLOT_WRITER_TYPE (&amp;dfsch_slot_writer_type)
 
 
 typedef struct dfsch_primitive_t {</diff>
      <filename>dfsch/types.h</filename>
    </modified>
    <modified>
      <diff>@@ -17,4 +17,12 @@ extern void dfsch__generic_register(dfsch_object_t *ctx);
 extern void dfsch__bignum_register(dfsch_object_t* ctx);
 extern void dfsch__conditions_register(dfsch_object_t* ctx);
 
+dfsch_object_t* dfsch__make_slot_accessor_for_slot(dfsch_type_t* type,
+                                                   dfsch_slot_t* slot);
+dfsch_object_t* dfsch__make_slot_reader_for_slot(dfsch_type_t* type,
+                                                 dfsch_slot_t* slot);
+dfsch_object_t* dfsch__make_slot_writer_for_slot(dfsch_type_t* type,
+                                                 dfsch_slot_t* slot);
+
+
 #endif</diff>
      <filename>src/internal.h</filename>
    </modified>
    <modified>
      <diff>@@ -178,6 +178,26 @@ DFSCH_DEFINE_PRIMITIVE(make_slot_accessor,
 
   return dfsch_make_slot_accessor(type, name);    
 }
+DFSCH_DEFINE_PRIMITIVE(make_slot_reader,
+                       &quot;Create specialized slot reader function&quot;){
+  dfsch_type_t* type;
+  char* name;
+  DFSCH_TYPE_ARG(args, type);
+  DFSCH_SYMBOL_ARG(args, name);
+  DFSCH_ARG_END(args);
+
+  return dfsch_make_slot_reader(type, name);    
+}
+DFSCH_DEFINE_PRIMITIVE(make_slot_writer,
+                       &quot;Create specialized slot writer function&quot;){
+  dfsch_type_t* type;
+  char* name;
+  DFSCH_TYPE_ARG(args, type);
+  DFSCH_SYMBOL_ARG(args, name);
+  DFSCH_ARG_END(args);
+
+  return dfsch_make_slot_writer(type, name);    
+}
 
 
 DFSCH_DEFINE_PRIMITIVE(get_list_annotation, 
@@ -990,6 +1010,10 @@ void dfsch__native_register(dfsch_object_t *ctx){
   dfsch_defconst_cstr(ctx, &quot;find-slot&quot;, DFSCH_PRIMITIVE_REF(find_slot));
   dfsch_defconst_cstr(ctx, &quot;make-slot-accessor&quot;, 
                       DFSCH_PRIMITIVE_REF(make_slot_accessor));
+  dfsch_defconst_cstr(ctx, &quot;make-slot-reader&quot;, 
+                      DFSCH_PRIMITIVE_REF(make_slot_reader));
+  dfsch_defconst_cstr(ctx, &quot;make-slot-writer&quot;, 
+                      DFSCH_PRIMITIVE_REF(make_slot_writer));
 
 
   dfsch__native_cxr_register(ctx);</diff>
      <filename>src/native.c</filename>
    </modified>
    <modified>
      <diff>@@ -308,6 +308,103 @@ dfsch_object_t* dfsch_make_slot_accessor(dfsch_type_t* type,
                                             dfsch_find_slot(type, slot));
 }
 
+static dfsch_object_t* slot_reader_apply(slot_accessor_t* sa,
+                                         dfsch_object_t* args,
+                                         dfsch_tail_escape_t* esc,
+                                         dfsch_object_t* context){
+  dfsch_object_t* instance;
+  dfsch_object_t* value;
+  DFSCH_OBJECT_ARG(args, instance);
+  DFSCH_ARG_END(args);
+
+  instance = DFSCH_ASSERT_INSTANCE(instance, sa-&gt;instance_class);
+
+  return dfsch_slot_ref(instance, sa-&gt;slot, 0);
+}
+static void slot_reader_write(slot_accessor_t* sa, 
+                              dfsch_writer_state_t* state){
+  dfsch_write_unreadable(state, (dfsch_object_t*)sa, 
+                         &quot;%s @ %s&quot;, sa-&gt;slot-&gt;name, sa-&gt;instance_class-&gt;name);
+}
+
+dfsch_type_t dfsch_slot_reader_type = {
+  .type          = DFSCH_STANDARD_TYPE,
+  .superclass    = DFSCH_FUNCTION_TYPE,
+  .size          = sizeof(slot_accessor_t),
+  .name          = &quot;slot-reader&quot;,
+  .apply         = (dfsch_type_apply_t)slot_accessor_apply,
+  .write         = (dfsch_type_write_t)slot_accessor_write,
+  .slots         = slot_accessor_slots,
+  .documentation = &quot;Slot reader allows direct reading of slot value&quot;
+};
+
+dfsch_object_t* dfsch__make_slot_reader_for_slot(dfsch_type_t* type,
+                                                 dfsch_slot_t* slot){
+  slot_accessor_t* sa = 
+    (slot_accessor_t*) dfsch_make_object(DFSCH_SLOT_READER_TYPE);
+  
+  sa-&gt;instance_class = type;
+  sa-&gt;slot = slot;
+  return (dfsch_object_t*) sa;
+}
+dfsch_object_t* dfsch_make_slot_reader(dfsch_type_t* type,
+                                         char* slot){
+  return dfsch__make_slot_reader_for_slot(type,
+                                          dfsch_find_slot(type, slot));
+}
+static dfsch_object_t* slot_writer_apply(slot_accessor_t* sa,
+                                         dfsch_object_t* args,
+                                         dfsch_tail_escape_t* esc,
+                                         dfsch_object_t* context){
+  dfsch_object_t* instance;
+  dfsch_object_t* value;
+  DFSCH_OBJECT_ARG(args, instance);
+  DFSCH_OBJECT_ARG_OPT(args, value, DFSCH_INVALID_OBJECT);
+  DFSCH_ARG_END(args);
+
+  instance = DFSCH_ASSERT_INSTANCE(instance, sa-&gt;instance_class);
+
+  if (value == DFSCH_INVALID_OBJECT){
+    return dfsch_slot_ref(instance, sa-&gt;slot, 0);
+  } else {
+    dfsch_slot_set(instance, sa-&gt;slot, value, 0);
+    return value;
+  }
+}
+
+static void slot_writer_write(slot_accessor_t* sa, 
+                                dfsch_writer_state_t* state){
+  dfsch_write_unreadable(state, (dfsch_object_t*)sa, 
+                         &quot;%s @ %s&quot;, sa-&gt;slot-&gt;name, sa-&gt;instance_class-&gt;name);
+}
+
+dfsch_type_t dfsch_slot_writer_type = {
+  .type          = DFSCH_STANDARD_TYPE,
+  .superclass    = DFSCH_FUNCTION_TYPE,
+  .size          = sizeof(slot_accessor_t),
+  .name          = &quot;slot-writer&quot;,
+  .apply         = (dfsch_type_apply_t)slot_accessor_apply,
+  .write         = (dfsch_type_write_t)slot_accessor_write,
+  .slots         = slot_accessor_slots,
+  .documentation = &quot;Slot writer allows direct modification of slot value&quot;
+};
+
+dfsch_object_t* dfsch__make_slot_writer_for_slot(dfsch_type_t* type,
+                                                 dfsch_slot_t* slot){
+  slot_accessor_t* sa = 
+    (slot_accessor_t*) dfsch_make_object(DFSCH_SLOT_WRITER_TYPE);
+
+  sa-&gt;instance_class = type;
+  sa-&gt;slot = slot;
+  return (dfsch_object_t*) sa;
+}
+dfsch_object_t* dfsch_make_slot_writer(dfsch_type_t* type,
+                                       char* slot){
+  return dfsch__make_slot_writer_for_slot(type,
+                                          dfsch_find_slot(type, slot));
+}
+
+
 
 dfsch_type_t dfsch_abstract_type = {
   DFSCH_META_TYPE,</diff>
      <filename>src/types.c</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b39edbfc30baed357089c77321863b853ee6d671</id>
    </parent>
  </parents>
  <author>
    <name>Ales Hakl</name>
    <email>ales@hakl.net</email>
  </author>
  <url>http://github.com/adh/dfsch/commit/11dc5f869081d1109b8d4df7024641f11862184e</url>
  <id>11dc5f869081d1109b8d4df7024641f11862184e</id>
  <committed-date>2009-11-15T18:07:48-08:00</committed-date>
  <authored-date>2009-11-15T18:07:48-08:00</authored-date>
  <message>Support not only slot-accessors but also readers and writers</message>
  <tree>f75622d1c17c9da70ce29f276f5afb7e31937e7a</tree>
  <committer>
    <name>Ales Hakl</name>
    <email>ales@hakl.net</email>
  </committer>
</commit>
