Recent Posts

Pages: [1] 2 3 ... 10
1
AutoLISP (Vanilla / Visual) / Re: More on LAMBDA please?
« Last post by Hrishikesh on July 22, 2017, 02:08:21 am »
Nice!!!
I was confused about this function, but after reading all posts in this topic I come to know how cleverly this function can be used in the code.
Thank you All..
2
Revit / Re: Revit Tips and Tricks
« Last post by rvhwlc on July 21, 2017, 12:26:15 pm »
it wrks.. good tip i can use that..
3
AutoLISP (Vanilla / Visual) / Re: More on LAMBDA please?
« Last post by John Kaul (Se7en) on July 21, 2017, 11:07:09 am »
Very interesting, I looked through my various routines and do not see any instances where I set a variable within the lambda call. Phew, I'm in the clear.

In a named function the variable remains until the session is closed. I'm quite intrigued as to how much lambda mimics defun.

:) "Modular design" is your friend -i.e. creating a bunch of small (single purpose) functions is good.

Good! ...post your research/findings. From what I remember, almost entirely; defun allows you to name your functions and call them. defun-q allows you to look up and access contents.
4
AutoLISP (Vanilla / Visual) / Re: More on LAMBDA please?
« Last post by Master_Shake on July 21, 2017, 10:56:01 am »
Very interesting, I looked through my various routines and do not see any instances where I set a variable within the lambda call. Phew, I'm in the clear.

In a named function the variable remains until the session is closed. I'm quite intrigued as to how much lambda mimics defun.
5
AutoLISP (Vanilla / Visual) / Re: More on LAMBDA please?
« Last post by John Kaul (Se7en) on July 21, 2017, 10:37:30 am »
Instinct has me saying no as the variable is contained within the lambda call?

No, sorry. You must still localize variables created within a lambda. Although, if you need to create variables within a lambda, it's a very good indication you should create a named function instead.

If for some reason you needed to set a variable within the lambda call, that variable would now be globally available in that session?


EDIT: ronjonp beat me to it.
***

Let me answer your question with a question (sorry).

What happens in a named function when you don't localize a variable?

Now, lets be clear here, we are quickly getting off topic here and going down the rabbit hole of "name resolution" -i.e. potentially breaking other parts of your/another program because of previously defined variables but, below is a link for you to read up on two different types of "scoping" and how different languages use it. Will the information gleaned from the following be useful? *meh* (maybe only if you get into other languages and/or compiler design--an absolute fascinating area to study if you ask me--but if you keep your AutoLisp variables localized, probably not).  Is it interesting? yeah.

https://en.wikipedia.org/wiki/Scope_(computer_science)#Static_versus_dynamic_scoping
6
AutoLISP (Vanilla / Visual) / Re: More on LAMBDA please?
« Last post by ronjonp on July 21, 2017, 09:36:14 am »
Instinct has me saying no as the variable is contained within the lambda call?

No, sorry. You must still localize variables created within a lambda. Although, if you need to create variables within a lambda, it's a very good indication you should create a named function instead.

If for some reason you needed to set a variable within the lambda call, that variable would now be globally available in that session?
Code - Auto/Visual Lisp: [Select]
  1. (mapcar '(lambda (n / i) (setq i n)) '(1 2 3 4 5 6 7 8))
  2. ;;;Command: !i
  3. ;;;nil
  4. (mapcar '(lambda (n) (setq i n)) '(1 2 3 4 5 6 7 8))
  5. ;;;Command: !i
  6. ;;;8
7
Revit / Re: Revit Tips and Tricks
« Last post by hudster on July 21, 2017, 09:09:20 am »
does not wrk for me..
Try it in the Properties palette
8
.NET / Re: Happy Birthday CADbloke
« Last post by Jeff H on July 21, 2017, 08:41:04 am »
Happy Birthday
9
AutoLISP (Vanilla / Visual) / Re: More on LAMBDA please?
« Last post by Master_Shake on July 21, 2017, 08:29:39 am »
Instinct has me saying no as the variable is contained within the lambda call?

No, sorry. You must still localize variables created within a lambda. Although, if you need to create variables within a lambda, it's a very good indication you should create a named function instead.

If for some reason you needed to set a variable within the lambda call, that variable would now be globally available in that session?
10
.NET / Re: Happy Birthday CADbloke
« Last post by Krushert on July 21, 2017, 07:47:24 am »
Happy Birthday, Sir?
Pages: [1] 2 3 ... 10