In my opinion defextend is fine the way it is, it has its similarities to CLOS's defmethod, which I would avidly abuse in my earlier lisp days.
The positive thing about adding a tagged predicate dispatch table, if implemented into "isa", would be the illusion of any object being a particular "type", provided it satisfies the predicate. In reality, the true type of the object would be cons or sym or whatever its value is.
One simple idea: The int/num difference could theoretically be moved into arc codespace via deftag. Primarily leave the number type "num" internally, but deduce if a number is an "int" via the tags table.
Example:
(deftag int
(and (isa _ 'num)
(is _ (round _))))
(isa 1.5 'int) => nil
(isa 1 'int) => t
One cool thing you could do is define tags for something like an object descriptor, or a class. Store whatever you need in cons cells, along with maybe a symbol at the head named "class:" or something, with "slots:" or "methods:" in that class. This could easily be checked if a particular cons resembles a "[class]" structured cons via a predicate, right? So deftag a predicate for "class". Then check if your object is a class-structed cons via "isa".
Try to think of it as an add-on, not a replacement. If you were to rewrite "isa" to first check if the type you're checking for is the builtin expression type or the tag, and if it's not, lookup the symbol in the "tags" table. If the key is not bound, it returns nil. If the key is bound, apply the predicate bound to the key to the value supplied to "isa".
You can indent a code block by 2 spaces to format it as code.
---
Your idea of types is similar to Predicate Dispatch[1]. I believe it's also similar to Racket's contracts[2].
This is an extremely powerful type system in the sense that you can express literally anything with it. However, I believe that a more restrictive type system can actually be better, because it provides more guarantees (especially at compile-time).
---
I don't think it's possible to pattern match on a function's arguments, body, and closure, simply because Racket doesn't expose those things.
I'm having more trouble understanding deftype. (I'd never come across it so far in my common lisp experience.) I couldn't tell what the benefit would be of your ((tags 'posnum) 0) examples over just a simple predicate. Won't it only be useful if arc actually got optional typing like common lisp?
(Also, I assume you're familiar with arc's approach to types using annotate and rep?)
I'm a student. Recently, I learning Altarica for analysis a model(system). But I don't kown how to do when I encounter some problems, like I mentioned above. Now, I try a case 'Design of a lift', when I analysis it's safety, it's report a error.
The command set arc.shell.preprocessor.default.command "/usr/bin/cpp" isn't legal arc (the one this forum is about). From googling around, the handbook you're reading (http://altarica.labri.fr/docs/arc-handbook.pdf) seems to be about that link I mentioned above.
Anyway, tell us what you are trying to do, and I'll tell you which of these is better for you :)
That's a good point. In Nulan, you can't redefine things (all variables are constant). I'm not so worried about performance right now. My main concern is simplicity, since implementing "do" as a macro introduces a lot of extra complexity (because Nulan compiles to JavaScript).
The first (and only) reason that comes to my mind is: efficiency. Calling a function that takes rest args means allocating a list at runtime; the usual expansion for "do" is a direct call to a lambda, which the Racket compiler seems able to handle with no runtime cost. Thus:
It is not too far-fetched an idea for a compiler to eliminate the runtime overhead of the calls to "do-func". Basically this would require assuming that "do-func" will not be redefined at runtime--which is permitted in Arc, so it would require the compiler to make optimistic assumptions and be prepared to invalidate the code when they are violated (i.e. if someone actually does redefine "do-func" at runtime). I've heard the best Javascript engines do this, but Racket does not.
In your use case, having a "do" that works at all is better than none, and I don't think there is any logical problem with doing so. (Strictly speaking, it makes it possible to "do" [!] more things, since you can't apply a macro.)
I've mainly just been learning the language. Working through some tutorials, reading books/articles, coding, etc. Did a few Project Euler problems, and now I'm working through SICP.
I burned a lot of time looking for my (not "the") perfect language, and finally settled on Racket for the dynamic language and OCaml for the statically typed language.
Now I'm trying see which problems are best suited to each of them.
Clojure has a lot of good things, but I've never been able to get past the dependency on the JVM, lack of tail calls, etc., but it's pretty darn concise.
I think anyone who is interested in a lisp has been positively influenced by Paul Graham, I certainly have.
You said this in the HN thread:
"I'm sure Arc is the wrong choice if I want to be as effective as possible in 6 months. If Arc is only the best choice if I want to be as effective as possible in 5+ years someone save me ;)"
The specific language is only one aspect of effectiveness - others include available libraries, an active contributing community, etc. I don't think there's reliable evidence that Arc will change enough in 3 years to fulfill your "effective as possible" goal.
Paul's last submission to his own forum has been over 5 years ago! And his last comment has been over 4 years ago. It would seem that he's not actively involved any more.
I was very excited to hear about Arc over 7 years ago, and I had high hopes that Paul might be the person to create a successful lisp and rally a great community. This has not happened, and I think it would be foolish to think this will change much in the next three years.
In the end, I ended up choosing Racket as my lisp - it made my short list to evaluate in part because Paul chose it to implement Arc :)
I'm certainly not trying to "save [you]", but I see many similarities between your quest for the most effective language and my own and countless others :) The language is very important, and concision is important, but you really need to evaluate the entire ecosystem to make a good choice.
I think I might be interested. I've been working on teaching people programming a lot, but haven't really had a chance to teach my favorite language. Are you thinking in person or over video conference?