Arc Forumnew | comments | leaders | submit | bramsundar's commentslogin
3 points by bramsundar 5931 days ago | link | parent | on: Eval Inquirry

The way I understand it, when you type in (eval '(- 3 4)) at the shell, eval passes its argument to ac. Ac in turn calls ac-call for things that are function calls. Ac-call converts an arc function call into an equivalent scheme form. During this process, it finds the underlying scheme name of an arc function by calling ac-var-ref. If you just pass in the actual function, it can't find the scheme name of the function and so can't evaluate it.

-----

1 point by bramsundar 5932 days ago | link | parent | on: Regexp name definition

I think that there are some nice possibilities lurking in this idea. Perhaps there could be a macro defined that modifies def to use this functionality (kind of like pm:def).

-----

2 points by bogomipz 5932 days ago | link

You can't make a macro create an infinite set of global bindings.

-----

3 points by bramsundar 5933 days ago | link | parent | on: A proposal for a module system...

I don't think so. Couldn't you just have use's macroexpansion add a global variable named foo?

-----

2 points by bogomipz 5933 days ago | link

Yes, I thought of that after I wrote the comment. Avoiding repetitions like this is exactly what macros are for. I guess I'm not used to thinking in lisp yet.

pau wants 'use to be a function, though, so there would have to be a separate macro, or the other way around, or something.

-----

2 points by almkglor 5933 days ago | link

  (def function-that-assigns-one-to-a-global-symbol-of-your-choice (s)
    (eval `(= ,s 1)))

-----


I'm still a noob, and my idea could be completely off base, but I think that it could be possible to devise a system that allows something like optional namespaces. The idea would be to have each symbol in the environment map to a table rather than directly to a function or variable. The table could have one entry per type (for example, pat's table could have one entry that's a macro, one that's a function, and one that's a variable). In standard cases, the value lookup function could return the entry that was last added to the hash table and thus mimic a Lisp-1 for all purposes. However, if the programmer specifies the type of a symbol, then the table would return the corresponding entry. There could be an fairly unobtrusive syntax for this. In one such syntax, the symbol pat would be:

pat (standard usage) #pat (function pat) `pat (macro pat) @pat (variable pat)

Then, pat-match:def would become `pm:def.

-----

1 point by almkglor 5933 days ago | link

No, my friend, the problem is the order of evaluation.

  (let pm (table)
      (pm 1))
  (mac pm ...)
versus:

  (mac pm ...)
  (let pm (table)
     (pm 1))
Unless you qualifiy everything with syntactic modifiers, order of evaluation will matter, and matter horribly.

-----

1 point by bramsundar 5933 days ago | link

I'm sorry, but could you explain your example a bit more? I don't think that I understand the issue here. If pm is redefined as a table through the let, why wouldn't we be able to access the macro version through the modifier? the table would clobber the variable version (@pm), but not the macro version right?

-----

2 points by almkglor 5933 days ago | link

Local variables never override macros. In the first case above, the let will return the expected value correctly, because pm at that time hasn't been defined yet. In the second case, it will not return the expected value, because pm is defined as a macro, and (pm 1) gets replaced with whatever (pm 1) expands to, let notwithstanding.

-----


Aren't macros already first-class?

-----