Arc Forumnew | comments | leaders | submit | drcode's commentslogin
3 points by drcode 6440 days ago | link | parent | on: OOP in Arc

http://arcfn.com/doc/template.html

-----

7 points by drcode 6440 days ago | link | parent | on: Implementation Question: Macros?

the way macros are expanded, the code is searched for references of the macro. If a referenence is found, the macro is executed and the code altered with the results of the macro.

The macroexpander will then "stupidly" rerun against the code, over and over again, until there are no more macros to expand.

This crude behavior allows you to have recursive macros, but it's not actually doing anything all that "smart"- I think you're reading more into the complexities of recursive macros than is probably there.

-----

3 points by PieSquared 6440 days ago | link

This is what I originally had in mind. As far as I can tell, this doesn't work for bytecode-compiled Lisp, correct? (Since it would compile it as a function call, although it's a macro...) So does that mean every implementation of Lisp has to have a single-pass interpreter in it?

-----

2 points by cchooper 6440 days ago | link

Well, every implementation of Lisp does indeed contain an interpreter: eval!

But the way Lisp compilers deal with recursive macros is to not allow them. From the Common Lisp spec:

"All macro and symbol macro calls appearing in the source code being compiled are expanded at compile time in such a way that they will not be expanded again at run time."

That rules out recursive macros. I think they're allowed when Lisp is being interpreted, but you should probably just not use them.

http://www.lisp.org/HyperSpec/Body/sec_3-2-2-2.html

-----

1 point by drcode 6444 days ago | link | parent | on: bug setting nested tables?

I can't duplicate your sample- Those two statements don't seem to be equivalent:

  arc> (= foo (table))
  #hash()
  arc> (= ('bar foo) 42)
  Error: "Can't set reference  bar #hash() 42"
  arc> (= foo!bar 42)
  42

-----

3 points by kens 6444 days ago | link

For the different table behavior, probably almkglor is using Anarki and drcode is using standard Arc. But your example looks like a bug to me:

  arc> (= ((foo (quote bar)) (quote baz)) 42)
  42
  arc> (= (foo!bar 'baz) 42)
  Error: "Can't invert  ((foo (quote bar)) (quote baz))"
Unless I've messed up the parentheses, those should be equivalent. I think the problem is that expand-metafn-call is being called by setforms when it shouldn't be. (Or alternatively, it shouldn't give up and die.) The example works if you first turn expand-metafn-call into a nop:

   (def expand-metafn-call (a b) (cons a b))

-----

1 point by almkglor 6444 days ago | link

No, it was a mistake by me: Anarki works similarly to ArcN in this case. Sorry for muddying the waters. ^^

The problem appears to be that the current '= was meant for use with the older ssyntax, which supports only : for composition. I'll take a better look maybe later, I'm just home from work, cooling off (very hot in the philippines right now)

The "invert" thing is really confusing, I didn't add docstrings to all the '= related stuff because of that. Me, I say refactor '=. LOL

Edit: Fixed on the git.

  (def metafn (x)
    (set x (ssyntax x))
    (and (acons x) (in (car x) 'compose 'complement)))

-----

2 points by drcode 6444 days ago | link

I wasn't expecting anyone to fix it- I was just wondering whether it was a bug :-)

Thanks almkglor and kens!

-----


I would guess that pg is hoping hash tables and alists can fill the roles that keyword parameters otherwise would be used for... "need keyword parameters? have the function accept an alist."

-----

4 points by almkglor 6445 days ago | link

Yes, but it's horribly inconvenient to access.

Same with defop. Accessing the GET/POST arguments to an operation is done via (arg req "foo"). It would have been worlds nicer if I could just define something like

  (defop foo-getter req
   (w/args (foo bar) req)
     (...))

-----

1 point by drcode 6448 days ago | link | parent | on: SVG

FYI- In case anyone is doing this, here is my version of the canonical sexp->xml function:

  (def xexp (x (o indent 0))
    (if acons.x
        (withs ((tg . lst) x
	        atts nil
	        pad (apply string (n-of indent " "))
  	      pretty (all acons lst))
  	(and lst (acons caar.lst) (= atts pop.lst))
  	(string pad 
  		"<" 
  		tg 
  		(tostring:map [pr " " car._ "=\"" cdr._ "\""] atts) 
  		">" 
  		(when pretty
  		  "\n")
  		(apply string (map [xexp _ (+ indent 3)] lst)) 
  		(when pretty
  		  pad)
  		"</" 
  		tg 
  		">\n"))
        string.x))
It assumes the standard PLT-scheme "xexpr" format...it is naive about character encoding right now BTW.

Example:

  (xexp '(ying (foo ((bar . baz)) "zing") (yang)))

  <ying>
     <foo bar="baz">zing</foo>
     <yang>
     </yang>
  </ying>
(fyi, 'tag makes html assumptions and breaks on most xml, nor is it really appropriate in style for building xml)

-----

1 point by drcode 6448 days ago | link | parent | on: SVG

Great tool- I will probably use it at some point...

Does that change in header* break regular web pages from serving? If not, how is it possible for Content-type to be the same for SVG and regular web pages?

-----

1 point by skenney26 6448 days ago | link

Changing the Content-type just lets the browser know that you're using xhtml rather than html. This will occasionally cause some issues when using svg.arc in combination with html.arc because the browser will expect your html to be xhtml compliant. This could probably be smoothed over by creating an xhtml version of html.arc and modifying the generated code so that its xhtml compliant.

-----

1 point by almkglor 6448 days ago | link

I think it would be better to completely update html.arc to use proper xhtml, or at least let the operator specify the MIME type.

-----

3 points by kens 6448 days ago | link

The server will need to specify arbitrary content-types eventually, and that's way easier than supporting xhtml, so specifying an arbitrary MIME type seems like the obvious solution to me. Also, the official MIME type for SVG is image/svg+xml, so trying to use xhtml both for SVG and HTML seems like a fragile hack.

-----

2 points by drcode 6448 days ago | link

Thanks for the great replies- I was actually also wondering how the RSS feed in news.arc deals with this... Is there some hack in there for overriding the Content-Type or are web browsers more forgiving for RSS feeds? I couldn't find any specific handling in news.arc for this issue on inspection the other day...

-----

4 points by kens2 6448 days ago | link

Firefox's Live HTTP Headers plugin tells me that news.ycombinator.com/rss has "Content-Type: text/html; charset=utf-8". I imagine RSS clients are not very strict about what they accept.

-----

1 point by drcode 6448 days ago | link

ahh... I need to get me that plugin :)

-----

4 points by drcode 6451 days ago | link | parent | on: quasiquote bug

I haven't seen this reported- I think I've encountered this error before in some complex code and figured it was user error :-)

-----


sounds like a good idea- maybe for the 2009 meeting :)

-----


crickets chirping

...

...

...

Doesn't look like there's enough East Coasters to maintain interest in this- Maybe another year :)

-Conrad

-----

2 points by lojic 6451 days ago | link

Waiting a while would be a good idea.

For me, it's way too early to tell whether Arc is worth a significant investment in time or not. The potential seems be there, but the actuality could be different.

I think pg has many responsibilities, and it's quite possible that other demands on his time could cause Arc to stall for a while (i.e. 2003-2008) or flatline.

-----

1 point by drcode 6452 days ago | link | parent | on: Comments on srv.arc

I think srv.arc is still pretty rough- I've been able to uses it with success, however, despite the quirks.

PG is not really a big fan of consistency. I think his reasoning is that consistency is another word for duplication and if you have it you're probably not using the most concise definition of your problem. I think this explains the inconsistencies in srv.arc. I suspect, as time goes on, this file will become smaller and cleaner as pg refactors it- However, I doubt it will become more "consistent".

One classic example of the lack of functions "for consistency's sake" in arc is that there is no 'cdar.

-----

4 points by kens2 6452 days ago | link

When you say you've been able to use srv.arc with success, do you mean the unmodified arc2.tar version or a patched version such as Anarki? Let me clarify that when I said above that srv.arc was broken, I was referring to the official version.

-----

1 point by drcode 6450 days ago | link

you are correct- I should have clarified I'm using the patched version with success :)

-----

More