Author Topic: Using global variables for fields?  (Read 1665 times)

0 Members and 1 Guest are viewing this topic.

Jeff H

  • Needs a day job
  • Posts: 6150
Using global variables for fields?
« on: November 24, 2011, 06:07:59 PM »
Just wondering,
I can not think of any reason to use it but was wondering do you guys ever have run something like
(setq !|<Sheet>*Num*|! number)
or what ever to make it available for a  Lispvariable field.
 

dgorsman

  • Water Moccasin
  • Posts: 2437
Re: Using global variables for fields?
« Reply #1 on: November 24, 2011, 07:02:50 PM »
I've considered it, then went with an Extension Dictionary/XRecord -based home-brew field alternative.  It just seemed a little less likely to generate grey hairs even with extra work up front.
If you are going to fly by the seat of your pants, expect friction burns.

try {GreatPower;}
   catch (notResponsible)
      {NextTime(PlanAhead);}
   finally
      {MasterBasics;}

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: Using global variables for fields?
« Reply #2 on: November 24, 2011, 11:17:17 PM »
Yep, global vars are generally bad! The lisp variable field is one case where you can't get away from them  :ugly:. Though you could use one of the user sysvars instead.

Another place is to store default user input between calls to your routine. Though here there are also alternatives, e.g. registry, file, blackboard, vlax-ldata, etc.

Rule of thumb is to always use localized vars, if you must go for global then try to distinguish them from other keywords. The official lisp naming convention is to prefix & suffix the name with asterisks.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.