Arc Forumnew | comments | leaders | submitlogin
Just a thought
1 point by skenney26 5952 days ago | 2 comments
It might be useful to be able to compose integers when indexing into a list in functional position. These would be equivalent:

  (car:cadr '(a (b c)))

  ('(a (b c)) 0:1)


3 points by drcode 5952 days ago | link

It's an interesting idea, but I'm not sure your use of ":" fits in well with the current concept of colon-based composition.

I would like to see this issue approached a little differently. I think we should:

  1. Make "." and "!" work in a nested fashion (as I implemented in http://arclanguage.org/item?id=7644)
  2. Allow the reader to treat a parenthesized item as an item that supports intrasymbol syntax.
Then, you could write the following to resolve the same way as your example:

  '(a (b c)).1.0
I'll probably try implementing something that can do this sooner or later...

-----

1 point by almkglor 5952 days ago | link

Alternatively, we could define compose as being:

  (= compose
     (reducer
       (fn () (err "compose requires at least one argument"))
       (fn (e) e)
       (fn (a b) (<base>compose a b))))

  (def reducer (f0 f1 f2)
    (fn rest
      (if
        (no rest)
          (f0)
        (no:cdr rest)
          (f1:car rest)
          ((afn (acc l)
             (if l
                 (self (f2 acc (car l)) (cdr l))
                 acc))
           (f2 (car rest) (cadr rest)) (cddr rest)))))
(as I proposed here: http://snapvm.blogspot.com/2008/08/base-functions.html)

Then we can redefine <base>compose as:

  (defm <base>compose ((t a int) (t b int))
    (annotate 'composed-int
      (cons a b)))
  (defm <base>compose ((t a composed-int) (t b int))
    (annotate 'composed-int
      (cons a b)))
Then we can redefine the call* table as an overloading of the <base>call function:

  (defm <base>call ((t l cons) (t v composed-int))
    (let (first second) (rep v)
      ((l first) second)))
> 2. Allow the reader to treat a parenthesized item as an item that supports intrasymbol syntax.

This is probably going to conflict with (a . d) format

-----