setq

Started by eddier, October 22, 2002, 07:33:05 AM

Previous topic - Next topic

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

Lutz

#1
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

HPW

#2
And all autolisp people love it! ;-)
Hans-Peter

Lutz

#3
>>> 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

HPW

#4
I think the autolisp people need them!



Of cource I only can speek for myself.
Hans-Peter

eddier

#5
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

Ryon

#6
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.
\"Give me a Kaypro 64 and a dial tone, and I can do anything!\"

Lutz

#7
>> 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

eddier

#8
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

Lutz

#9
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

Kumar

#10
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 !

Lutz

#11
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