comparison src/eval.c @ 753:8a4c2c149ec2

*** empty log message ***
author Jim Blandy <jimb@redhat.com>
date Wed, 08 Jul 1992 22:47:39 +0000
parents a8d94735277e
children 427299469901
comparison
equal deleted inserted replaced
752:f7c08f6bd753 753:8a4c2c149ec2
741 definitions to shadow the loaded ones for use in file byte-compilation.") 741 definitions to shadow the loaded ones for use in file byte-compilation.")
742 (form, env) 742 (form, env)
743 register Lisp_Object form; 743 register Lisp_Object form;
744 Lisp_Object env; 744 Lisp_Object env;
745 { 745 {
746 /* With cleanups from Hallvard Furuseth. */
746 register Lisp_Object expander, sym, def, tem; 747 register Lisp_Object expander, sym, def, tem;
747 748
748 while (1) 749 while (1)
749 { 750 {
750 /* Come back here each time we expand a macro call, 751 /* Come back here each time we expand a macro call,
751 in case it expands into another macro call. */ 752 in case it expands into another macro call. */
752 if (XTYPE (form) != Lisp_Cons) 753 if (XTYPE (form) != Lisp_Cons)
753 break; 754 break;
754 sym = XCONS (form)->car; 755 /* Set SYM, give DEF and TEM right values in case SYM is not a symbol. */
755 /* Detect ((macro lambda ...) ...) */ 756 def = sym = XCONS (form)->car;
756 if (XTYPE (sym) == Lisp_Cons 757 tem = Qnil;
757 && EQ (XCONS (sym)->car, Qmacro))
758 {
759 expander = XCONS (sym)->cdr;
760 goto explicit;
761 }
762 if (XTYPE (sym) != Lisp_Symbol)
763 break;
764 /* Trace symbols aliases to other symbols 758 /* Trace symbols aliases to other symbols
765 until we get a symbol that is not an alias. */ 759 until we get a symbol that is not an alias. */
766 while (1) 760 while (XTYPE (def) == Lisp_Symbol)
767 { 761 {
768 QUIT; 762 QUIT;
763 sym = def;
769 tem = Fassq (sym, env); 764 tem = Fassq (sym, env);
770 if (NILP (tem)) 765 if (NILP (tem))
771 { 766 {
772 def = XSYMBOL (sym)->function; 767 def = XSYMBOL (sym)->function;
773 if (XTYPE (def) == Lisp_Symbol && !EQ (def, Qunbound)) 768 if (!EQ (def, Qunbound))
774 sym = def; 769 continue;
775 else
776 break;
777 } 770 }
778 else 771 break;
779 {
780 #if 0 /* This is turned off because it caused an element (foo . bar)
781 to have the effect of defining foo as an alias for the macro bar.
782 That is inconsistent; bar should be a function to expand foo. */
783 if (XTYPE (tem) == Lisp_Cons
784 && XTYPE (XCONS (tem)->cdr) == Lisp_Symbol)
785 sym = XCONS (tem)->cdr;
786 else
787 #endif
788 break;
789 }
790 } 772 }
791 /* Right now TEM is the result from SYM in ENV, 773 /* Right now TEM is the result from SYM in ENV,
792 and if TEM is nil then DEF is SYM's function definition. */ 774 and if TEM is nil then DEF is SYM's function definition. */
793 if (NILP (tem)) 775 if (NILP (tem))
794 { 776 {
816 { 798 {
817 expander = XCONS (tem)->cdr; 799 expander = XCONS (tem)->cdr;
818 if (NILP (expander)) 800 if (NILP (expander))
819 break; 801 break;
820 } 802 }
821 explicit:
822 form = apply1 (expander, XCONS (form)->cdr); 803 form = apply1 (expander, XCONS (form)->cdr);
823 } 804 }
824 return form; 805 return form;
825 } 806 }
826 807