Arc Forumnew | comments | leaders | submitlogin
Simple example of a metafn place using complement
3 points by dido 4710 days ago | 1 comment
As some of you guys know, I've been working on a C implementation of Arc (Arcueid), and am in the process of testing most of the definitions in arc3's arc.arc to see if Arcueid's core can handle these definitions. Making unit tests for all these have cleared out a raft of bugs and let me know what else is missing. Now I've gotten to the code that creates Arc's places and setforms, to learn there are such things as metafn places (involving the use of compose and complement). I can see how compose could be used, e.g.:

  (= (car:cdr x) 'foo)
but complement? I can't think of a way to make a place using the complement function. Can anyone give an example?


4 points by rocketnia 4710 days ago | link

There is no example in official Arc. If we're talking hypothetically, here's one way to make sense of it:

  arc> (= x '(2))
  (2)
  arc> (= (~car x) t)
  t
  arc> (~car x)
  t
  arc> x
  (nil)
  arc> (= (~x 0) nil)
  nil
  arc> (~x 0)
  nil
  arc> x
  (t)
Since (~foo ...) only ever returns nil or t, this kind of place can't faithfully store other values:

  arc> (= (~x 0) "something unique and special")
  Error: Can't assign "something unique and special" as boolean
  
  -- or --
  
  arc> (= (~x 0) "something unique and special")
  "something unique and special"
  arc> (~x 0)
  t
I don't see much purpose to implementing this feature, since every time someone would type (= (~foo bar) baz), they could just type (= foo.bar no.baz) instead.

-----