Arc Forumnew | comments | leaders | submitlogin

That is indeed quite lame: http://arclanguage.github.io/ref/io.html#readline

Edit 8 minutes later: seems to work fine for me on anarki.

  arc> (fromfile "x" (drain:readline))
  ("This is the first line." "After this line there is an empty line." "" "After this line there are two empty lines." "" "" "This is the last line.")
  arc> (fromstring "\n\na\nc\n\nd" (drain:readline))
  ("" "" "a" "c" "" "d")
Were you running arc3.1 or something?
2 points by zck 4135 days ago | link | parent | on: Reading a text file into a list or an array

Now that I've been able to test it, this works, as long as you don't have empty lines in your file. If you do, it works...oddly:

This file:

    This is the first line.
    After this line there is an empty line.
    
    After this line there are two empty lines.
    
    
    This is the last line.

results in this list:

    arc> (read-all "/home/zck/test.txt")
    ("This is the first line." "After this line there is an empty line." "\nAfter this line there are two empty lines." "\n" "This is the last line.")
Note how the newline after the first empty line gets glommed onto the line after it? Yech. But it does work exactly as expected if each line is nonempty.
2 points by c-a-smallwood 4136 days ago | link | parent | on: The super loop (fun macro exercise)

I've thought about things like this quite a bit, mainly because I'm one of the few people who actually do like CL's LOOP macro. I think it'd be pretty fun indeed to try and write something in Arc.
2 points by zck 4136 days ago | link | parent | on: Reading a text file into a list or an array

untested code:

  (def read-all (filename)
       (w/infile file filename
                 (drain (readline file))))
`drain` executes its argument repeatedly until it returns nil. (https://arclanguage.github.io/ref/iteration.html#drain)

`readline` returns nil when there's nothing more to read (https://arclanguage.github.io/ref/io.html#readline)

1 point by edeion 4138 days ago | link | parent | on: Why I don't sell Lisp software (2007)

So sad.
4 points by evanrmurphy 4140 days ago | link | parent | on: Try Arc down for a few days

Ok, it's back up now.
2 points by akkartik 4145 days ago | link | parent | on: Try Arc down for a few days

Nick and I spent some time trying to recreate the submission problem. I did see it once, but it never happened after I showed it to Nick :) I'll continue watching for it.
2 points by kogir 4145 days ago | link | parent | on: Testing link submission

Seems to have worked?
2 points by evanrmurphy 4145 days ago | link | parent | on: Try Arc down for a few days

Clickable: http://tryarc.org/2015/03/04/upcoming-downtime-for-a-few-day...

Sorry, I tried to submit a link rather than a text post with a URL but Arc Forum wouldn't let me.

3 points by akkartik 4150 days ago | link | parent | on: How do you see what a macro expands to?

  (mac test a `(list ,a))
vs

  (mac test (a) `(list ,a))
Does that help?

???
3 points by akkartik 4151 days ago | link | parent | on: How do you see what a macro expands to?

Rest arg :)

Why does your example return (list (a)) instead of (list a)?

Steve

3 points by lark 4151 days ago | link | parent | on: How do you see what a macro expands to?

Thank you.
5 points by Pauan 4152 days ago | link | parent | on: How do you see what a macro expands to?

First off, you're seeing the macro-expansion of the "mac" macro, not the macro-expansion of the "test" macro. Try this instead:

  arc> (mac test a `(list ,a))
  arc> (macex '(test a))
Secondly, you can also use "macex1" to only expand it one time:

  arc> (macex1 '(mac test a `(list ,a)))
Sometimes this produces nicer output.
1 point by akkartik 4154 days ago | link | parent | on: Two useful language extension ideas

Just submitted and then saw your comment: https://github.com/arclanguage/anarki/commit/4cfe8c36e5.

Feel free to change further or to revert if it doesn't look right. Nothing is set in stone.

2 points by c-a-smallwood 4154 days ago | link | parent | on: Two useful language extension ideas

At the same time, I kind of feel like having a dash makes it deviate a little... And "defisa" just doesn't look right in my opinion. Do you think having a slight variance would be ok?
2 points by c-a-smallwood 4154 days ago | link | parent | on: Two useful language extension ideas

I like both ideas, they flow well with arc and anarki's naming scheme. Something like the following:

  (def-isa list (alist _))
2 points by c-a-smallwood 4154 days ago | link | parent | on: Two useful language extension ideas

Works great!
2 points by akkartik 4154 days ago | link | parent | on: Two useful language extension ideas

Playing with it some more, I have a few ideas/tweaks :)

1. Maybe we should rename deftype to def-isa since it only overrides isa, not type or coerce? That would also fit with how we use defcall to extend coercion to function, defcoerce to extend coerce, defset to extend assignment, etc.

2. I'm thinking of renaming the types table to type-predicates.

What do you think?

2 points by akkartik 4154 days ago | link | parent | on: Two useful language extension ideas

Thanks! I see it now. Amazing how much difference it makes to see it working in a known context.

I figured out why '=' wasn't working; we were redefining it further down the file. I fixed it by moving deftype to later, and now we can go back to '='. https://github.com/arclanguage/anarki/commit/2c12a9e4f8. Does that seem reasonable?

2 points by c-a-smallwood 4154 days ago | link | parent | on: Two useful language extension ideas

Pull request submitted. I had to fix a small bug that I didn't check for before... It works now :)
2 points by c-a-smallwood 4154 days ago | link | parent | on: Two useful language extension ideas

No, I can't stand Cygwin. I actually wrote the original 1200 lines of the interpreter on Fedora. My goal was to try to keep it completely portable C code. As of right now, on my machine, I create a Win32 Console app in Visual Studio to compile MTL on Windows, and it works just fine. Initially I had some segfaults, but it was mainly due to the lack of exception checks and null checks... So as far as I can tell, it's pretty much cross platform at the moment.

In the few minutes I've used anarki, it seems to work just fine :) I just run it in the command-line Racket app by running:

  (load "C:/anarki/boot.scm")
  (tl)
2 points by akkartik 4154 days ago | link | parent | on: Two useful language extension ideas

I think you're in the best position to judge :) Maybe play with a little example program and see what looks best in its context? If it doesn't seem to matter just pick one. We can always change it later.

I have to admit, I'm not sure how long it's been since somebody tried installing anarki on windows. Let me know when you run into problems. I'm actually amazed that I was able to get mtl running on linux so easily. Are you using cygwin?

2 points by c-a-smallwood 4154 days ago | link | parent | on: Two useful language extension ideas

In truth, it's been about 5-6 years since I've collaborated on anyone's code that isn't my own. I'd love to submit a pull request :) I'm installing Racket & Anarki on this windows machine this morning to see about getting a working version. Do you think "deftype" would be ok for the macro name? Any other suggestions? Maybe something in the spirit of original Arc, like "pred" for predicate or something?
2 points by akkartik 4154 days ago | link | parent | on: Two useful language extension ideas

Nice!

I've criticized sweet-exprs in the past as trying to do too much (https://news.ycombinator.com/item?id=8507385). But the original subset you're implementing here is very useful.

(I'm still opposed to neoteric expressions, because parens before function is The One True Way, especially in the presence of infix: http://arclanguage.org/item?id=16924. But I won't agitate for it again since n-exprs are optional :)

BTW, in searching for the above link I ran across http://arclanguage.org/item?id=18261, which you might find interesting if you hadn't already seen it.

2 points by c-a-smallwood 4154 days ago | link | parent | on: Two useful language extension ideas

Essentially the syntax is the same, but with one difference: If the body of the bracket function ONLY consists of a dotted expression, the body of the function IS that expression. Example:

  Anarki:
  [car._] => (fn (_) ((car _))) ; note extra parens
  [car _] => (fn (_) (car _))

  MTL:
  [_.car] => (fn (_) (car _))
  [car _] => (fn (_) (car _))
I mainly took this step to take advantage of having support for multiple "dots", Example:

  x.car.type => (type (car x))
It's just more readable in my opinion. In regards to the second part of your post, it's because of a bug in my number reader, which I'll fix soon. Thanks for pointing it out!

I plan to add n-expression support into bracket functions, too. It would make the following work:

  ([_(1)] '(1 2 3)) => 2
1 point by akkartik 4154 days ago | link | parent | on: Two useful language extension ideas

I'm curious how your square bracket syntax works. In particular, why does this work?

  mtl> ([_.car] '(1 2 3))
  1
But not this?

  mtl> ([0._] '(1 2 3))
  Exception: Symbol is not bound: 0
2 points by akkartik 4154 days ago | link | parent | on: Two useful language extension ideas

tag and isa already mean something in anarki. Any suggestions on how we integrate the existing type support with deftag? Feel free to send a pull request!
2 points by c-a-smallwood 4155 days ago | link | parent | on: Two useful language extension ideas

I've got a simple, functional version that could easily be transcribed in anarki. Here it is in MTL:

https://github.com/camden-smallwood/mtl/blob/master/core.l#L...

More