Arc Forumnew | comments | leaders | submit | almkglor's commentslogin
2 points by almkglor 6441 days ago | link | parent | on: Obama?

http://www.paulgraham.com/info.html

He does have an email address.

-----

1 point by poppers 6441 days ago | link

Thanks. Sorry for the spam then. Thankfully PG's spam filter did not delete my message.

-----

5 points by almkglor 6441 days ago | link | parent | on: On Lisp?

http://www.paulgraham.com/onlisptext.html

-----

1 point by eds 6440 days ago | link

Still, it would be nice to have real printed copies of On Lisp instead of having to print it all yourself.

-----

3 points by skrishna23 6438 days ago | link

Well, why not use some service like lulu.com to print this out as a book ?

-----

1 point by eds 6436 days ago | link

Perhaps, but what about copyright issues?

-----

1 point by almkglor 6440 days ago | link

Well, yes, I suppose so ^^

-----

1 point by almkglor 6441 days ago | link | parent | on: Where are the fast dynamic languages?

We may need to define extensions for optimization purposes though.

As an aside, defm may help, by ensuring that certain variables always belong to certain types (although the other problem is with regards to . rest arguments). Really, having an optional type declaration is good, and helps make it easier for the compiler to optimize.

-----


Idea: define-for-syntax

Looking through how Chicken compiler works, it seems that Chicken detects syntax-case and friends, performing them at compile-time, However if a macro needs to use a function, the function should be defined using define-for-syntax. Perhaps our rules for macros:

1. Should be defined using 'mac

2. Any form that has a 'mac will be executed at compile-time, with the 'mac transformed to a macro definition:

  (let internal-fun
       (fn (x) `(foo ,x))
    (mac my-macro (z)
      (internal-fun z)))
3. Any functions that need to be used directly by macros must be added either in a 'let form like the above, or defined using 'def-syn.

Idea: Library

We probably need some sort of library system, like the part which handles 'ccc: add it only if it's needed, otherwise leave it out.

Hmm.

Idea: optional and varargs

It seems to me that optional variables might be implementable as varargs forms. Not sure though.

  (fn (foo (o niaw nil) (o grr niaw))
   (body foo niaw grr))

  =>

  (fn (foo . gs42)
    (with (niaw (if gs42 (car gs42) nil)
           gs42 (cdr gs42))
      (with (grr (if gs42 (car gs42) niaw)
             gs42 (cdr gs42))
        (body foo niaw grr))))
So all we need is to implement var-args, and special-case optional variables as above.

-----

2 points by binx 6441 days ago | link

An extra hash argument can implement both optional and named args. Representing optional args as varargs would complicate the source transformation when they are used simultaneously in the same function.

-----

2 points by almkglor 6441 days ago | link

Not really:

  (fn (niaw (o hmm) . rest)
    (body niaw hmm rest))

  =>

  (fn (niaw . gs42)
    (with (hmm (if gs42 (car gs42) nil)
           gs42 (cdr gs42))
      (let rest gs42
        (body niaw hmm rest))))
It's not at all complicated: just make the last argument take the value of your temporary rest argument. Edit: This is what I did in creating the p-m macro, and it works.

I'm not sure how adding an extra hash would work well if I might pass several different functions, with different optarg names:

  (set p1
    (fn (hmm (o niaw))
      (body hmm niaw)))
  (set p2
    (fn (hmm (o arf))
      (body hmm arf)))
  (set p3
    (fn rest
      (body rest)))
  ((if (something)
       p1
     (something-else)
       p2
       p3)
  1 42)
Edit: My approach appears to be somewhat similar to what pg did in the Scheme version - cref ac-fn, ac-complex-fn, ac-complex-args, ac-complex-opt in ac.scm

Since code is spec (grumble) I think it might be better to follow mostly what pg did, although I dunno, not sure ^^. How can passing in a hash table seamlessly emulate the same functionality while improving performance?

-----

1 point by binx 6441 days ago | link

The define-for-syntax form is just a sub-feature of CL's eval-when, why don't us give a full eval-when support?

-----

1 point by almkglor 6441 days ago | link

Hmm. I'll think about that.

eval-when would be used, I think, only to differentiate between compile-time and run-time. It's not a part yet of ArcN. Hmm. Lemme think more deeply about this.

Edit: This seems like a good idea ^^

-----


Okay^^. Want to post a draft here so you can get reactions about it?

-----

1 point by wfarr 6441 days ago | link

I should have one by tonight, ideally.

-----

1 point by wfarr 6439 days ago | link

I've dropped you an email. =)

-----


As an aside, both me and raymyers have written basic module systems.

The hardest part (which we haven't built yet) is macros, both private in the module, and macros defined by the module for use by external code/other modules.

-----


Regarding 'if: We could insert a code walker which transforms 4 or more arg forms of 'if to conventional 'if:

  (if
    (hmm)
      (niaw)
    (grr)
      (woof))

  =>

  (if (hmm)
      (niaw)
      (if (grr)
          (woof)))
Also, we can use Anarki-specific 'ssexpand and 'ssyntax to transform symbol syntax, probably by inserting another step in the compile process (which is why I suggested structuring arc2c in: http://arclanguage.com/item?id=5598 ); However ssyntax which transforms to ((compose a b) ...) has to be transformed to (a (b ...)) because of macros, such as p-m:def.

-----

1 point by sacado 6441 days ago | link

Excellent idea :)

-----

4 points by almkglor 6441 days ago | link

wrote a code walker, on the git.

Basically to use:

  (def your-function (argument-data)
    (code-walk a-variable argument-data
      (if
        (something-you-need-to-process a-variable)
          `(stuff ,(car a-variable) ,(cdr a-variable))
        ; else return the variable as-is
          a-variable)))
code-walk will automatically skip ' as well as the constant parts of `(), but will reprocess when it sees a comma or comma-at `( ,...)

See to-3-if sample

Also I removed the err in 'source - since part of codegen now emits the code in list form rather than AST, source just passes it if it's not an AST

Edit: also added ssyntax support

-----


I can't find debut.arc in Anarki either.

Some more Anarki-related questions:

1. Do you intend to use Anarki-specific features? This is so that I know if I can use Anarki in any mods.

2. Do you intend to still use the arc2c copy on Anarki, say as a stable branch?

-----

1 point by sacado 6441 days ago | link

Yep. Just checked that. In fact, "debut.arc" was renamed "structs.arc". Just change this in "arc2c.arc", and it will be working.

1. Yes, I will probably. I only work with the Anarki version, so when I'm finding something useful in the source, I don't even know if it's "official" or not.

2. Yes. Using Anarki as a repository for the stable versions of arc2c seems a good idea.

-----

1 point by almkglor 6441 days ago | link

Also, another question - Anarki has a CONVENTIONS file, will we be following this too? One Anarki convention that isn't followed is with regards to tabs and indentation, is it OK to change the tabs to follow Anarki conventions or do you prefer the current indentation?

-----

1 point by sacado 6441 days ago | link

Oh, sure, I never really checked the CONVENTIONS file, but I think it's better to indent this way (it's the tradition after all:). I usually don't do it naturally because it's not the way I learnt it, but I guess I should follow the conventions anyway. So, OK, let's change the tabs.

-----

2 points by almkglor 6441 days ago | link | parent | on: Comments on srv.arc

My bet is, this is a thinko by pg. He planned to restrict arform to not emitting anything, but forgot to actually put the restriction.

The code for both forms are quite a few lines apart too.

http://www.paulgraham.com/gh.html section: recognition

Edit: after some time scanning through the code - it seems that arformh's time is measured, but arform's time is not. Or vice versa, I could've gotten confused.

Cref: rfnurl* and rfnurl2* . rfnurl* is "r", r is (defopr r ...), defopr is (... (defop-raw ...)), defop-raw is (... (save-optime ...))

rfunurl2* is "y", y is (defopr-raw y ...), defopr-raw doesn't add any code to the body: (fn ,parms ,@body)

-----


  ERROR: Write permission to sacado/arc2c denied to AmkG.
  fatal: The remote end hung up unexpectedly
  error: failed to push to 'git@github.com:sacado/arc2c.git'

-----

1 point by sacado 6441 days ago | link

Hmm... Thaks for the information. I can't see how I can say "this git is open to everyone" in the config menus. Any idea ?

-----

1 point by almkglor 6441 days ago | link

Hmm. Can't seem to do this either. Erk.

I suppose nex3 specifically requested github for special treatment of Anarki? ^^

-----

2 points by sacado 6441 days ago | link

Anyway, I can add specifically anyone who asks me to. You are now an authorized "committer", btw.

-----

2 points by almkglor 6441 days ago | link

Thanks, I'll push something in maybe an hour or two, am at the office.

The push I was going to make was simply to wrap some of the private functions in codegen.arc in a 'let form.

-----

More