Page 1 of 1

setq

Posted: Tue Oct 22, 2002 2:33 pm
by eddier
Lutz,

I know this is picking fluff but, why have a setq? You have two different functions doing the same thing.

The multiple args for set is nice :)

Eddie

Posted: Tue Oct 22, 2002 3:10 pm
by Lutz
It hasn't been in newLISP for 11 years (or only as a macro). setq has the advantage that it doesn't need the quote and is for that reason 50% faster, all LISPs really have them both the 'set' and the 'setq' or 'set!' and over the years I have been asked for it again and again. The last push was multiple arguments in set, now it becomes obvious, that setq is much less typing, because you don't need a quote before every symbol.

Lutz

Posted: Tue Oct 22, 2002 3:30 pm
by HPW
And all autolisp people love it! ;-)

Posted: Tue Oct 22, 2002 7:25 pm
by Lutz
>>> And all autolisp people love it! ;-)

And actually I do too :).

These decisions are not easy and I am pretty happy that after 10+ years newLISP is still pretty small compared to other languages. It's always a conflict, because for the person asking for a new feature it is very often of great importance.

I wonder what else people have on their minds for added functions in newLISP, and what are the functions, nobody cares about? I.e. I never have used 'member' in my entire life, but it is one of those 'traditional' LISP functions everybody expects in a LISP, but do we really need it with all the other high-level list processing stuff in there?

Lutz

Posted: Tue Oct 22, 2002 8:03 pm
by HPW
I think the autolisp people need them!

Of cource I only can speek for myself.

Posted: Wed Oct 23, 2002 2:48 pm
by eddier
I think I used member one time but I could have used find just as easily.

Yep. Tradeoffs are a pain.

I thought about asking for find to return regex output on regular expression matches and doing away with regex but then find returns a position and it might be confusing for find to return an integer for some things and list for others.

It's nice to have a minimal and elegant set of functions to keep a language easy to learn and use. But I have to admit it's REAL nice when there is a pre-built function that really fits the bill without having to write it yourself.

Eddie

Understandability

Posted: Wed Oct 23, 2002 4:15 pm
by Ryon
I am in favor of the minimal and elegant set of functions, which could then be used to build a set or sets of extension functions to be loaded separately. Clean. Well-factored. Understandable.

The functions could then be optimized by re-writing at a lower level, if necessary for performance reasons, but only after the solution is understood.

Posted: Wed Oct 23, 2002 5:18 pm
by Lutz
>> I am in favor of the minimal and elegant set of functions,

that is pretty much my philosophy too, but sometimes I have to water it down when too many are asking for it and sometimes I am one of them. But I think overall that philosophy is pretty much maintained in newLISP.

About regex: at this moment only 'find', 'replace' and 'regex' use regular expressions. when I went through all string functions checking for the possibility of regex, this is what I came up with. Other functions like 'starts-with', 'ends-with' can be easily done in the first three. I wonder if anybody has additional suggestions.

Lutz

Posted: Wed Oct 23, 2002 8:37 pm
by eddier
I agree Lutz, I see no reason to use starts-with or ends-with. However, some users might not want to learn regular expression syntax.

How about sublist and substring? Very similar operations except one is list and the other is a string. How about a poly morph function called slice or partition, ...?

Eddie

Posted: Thu Oct 24, 2002 5:13 am
by Lutz
Collapsing 'substring' and 'sublist' sounds like a good idea! I vote for 'slice' as the name. I could let 'sublist' and 'substring' point to it and then fade them out later (like 'concat' -> 'append').

Lutz

Posted: Mon Feb 03, 2003 10:14 pm
by Kumar
I like subseq as a substring/sublist substitute. Severals reasons:
-Its already in Common Lisp, it reminds you better about what it does.
it reminds also where does it come from, i.e. substring/sublist

Functions' names should be 'selfexplanatory', as far as possible.
As for setq, I agree it has been there for a long time, and left everyone satisfied.

On other more specialised functions, I'd rather encourage the creation and sharing of specialized libraries. -after all, thats what Lisp escells at -modular, reusable code - just paraphrasing Paul Graham !
Still , I think any Lisp should be proudly strong on list-managing functions !

Posted: Mon Feb 03, 2003 11:50 pm
by Lutz
Wish I would have known before version 7.0.1 ;-), collapsing to substring and sublist to 'slice' was released in that version. Doing the following, you can make 'subseq' also work:

(set 'subseq slice)

There is no speed penalty in doing this.

Lutz