Git Product home page Git Product logo

arclanguage / anarki Goto Github PK

View Code? Open in Web Editor NEW
1.2K 70.0 160.0 3.45 MB

Community-managed fork of the Arc dialect of Lisp; for commit privileges submit a pull request.

Home Page: http://arclanguage.github.io

License: Other

Shell 0.42% Emacs Lisp 3.93% Python 0.34% Perl 6.45% XSLT 0.34% Arc 74.86% Racket 9.34% Batchfile 0.04% Terra 1.00% CSS 0.70% JavaScript 0.12% Vim Script 2.47%
arc lisp webapp lisp-1 racket-lang linux darwin macos

anarki's Introduction

Anarki CI

A publicly modifiable 'wiki-like' fork of Arc Lisp

The intention is to be extremely permissive in accepting patches. For commit privileges, just submit your first pull request or ask on Arc Language Forum.

Getting started

Installation

First install Racket (v7.7 or later), then in a terminal, run:

$ raco pkg install sha
$ git clone http://github.com/arclanguage/anarki
$ cd anarki

You can start the interactive repl with:

$ ./arc.sh

Or start news (and the repl) with:

$ cd apps/news
$ ./run-news

Tutorial

If you're new to Arc, or Lisp in general, a good starting point is the Tutorial.

Documentation and help

If you run into trouble, check

News Site

Anarki comes bundled with News, a Hacker News style app.

Admins

To run News, first pick your (the admin's) username,

$ cd anarki/apps/news
$ mkdir www
$ echo __username__ > www/admins

You can have multiple admins. Add them all to www/admins, separated by whitespace.

Starting the server

Warning: If you are already running a News site, migrating to this fork might mess up your site's data. Come talk to us first, and be sure to make a backup before the migration.

Now bring up the server,

$ ./run-news

There'll be a pause while the server loads up, with some messages, then you'll see the arc> prompt.

Go to http://localhost:8080. Click on login, and create the account for your username. You should now be logged in as an admin.

(Don't worry about user break or error writing messages.)

Customization

To customize News, change the variables at the top of apps/news/news.arc. To change the port your server runs at, modify apps/news/run-news.arc.

Any interactive changes to the prompt will be reflected immediately in the server, without needing to restart it. Hence if you make any changes to apps/news/news.arc, you can load them, by typing (load "apps/news/news.arc") in the repl. If you stop the server or it dies for some reason, previously entered commands are available in the command history (at least if you have Readline installed).

HTTPS

You may want to serve News securely over HTTPS. An example configuration for running Nginx with SSL as a reverse proxy for News can be found in anarki/extras/news.nginx.conf.

Resetting passwords

For password reset mails to be sent out, your must set up an email account to send these from,

$ echo "[email protected]" > www/app-email  ; email
$ echo "smtp.example.com" >> www/app-email     ; smtp server
$ echo "[email protected]" >> www/app-email  ; user
$ echo "1234" >> www/app-email                 ; password

Development

Tests

Anarki has thorough automated tests.

# start in the anarki directory
$ ./arc.sh
arc> (load "tests.arc")

Anarki is explicitly not constrained to maintain compatibility with upstream releases, and compatibility status may swing wildly from commit to commit depending on who takes an interest. To see a list of what's different, type (incompatibilities) at the repl. If you make an incompatible change, please update this list.

Anybody is welcome to make changes to Anarki, but please make sure the tests continue to pass. Since we rely on the unit-test.arc test harness, please also run its tests before committing any changes:

$ ./arc.sh (require 'lib/unit-test.arc/unit-test.arc) (load "unit-test.arc/tests.arc") (test-and-error-on-failure)

Racket interop

Racket expressions can be evaluated with the ($ ...) syntax. For instance, (($ crypto-random-bytes) 16) obtains the crypto-random-bytes function from Racket and makes a call to it.

If you write lots of Racket code and you just want to use Anarki for part of a bigger project, you can raco pkg install anarki and use Anarki to write Racket modules:

#lang anarki
(:provide function-for-use-in-racket)

(= racket-import ($.dynamic-require ...))
(load "relative/path.arc")

(def utility-for-use-in-racket (x)
  (* x (racket-import x))

Scope

Note that Anarki does not have private module scopes; the (:provide ...) section is just there to make it easy to require an Anarki-based library from Racket.

Keyword arguments

Anarki has some issues passing keyword arguments to Racket functions, but Racket's keyword-apply can be used for that.

anarki's People

Contributors

akkartik avatar alimoeeny avatar awwx avatar blackstag avatar brandonbloom avatar brianru avatar camden-smallwood avatar dram avatar hasenj avatar hjek avatar huetsch avatar jazzdev avatar kennethrapp avatar kinnardian avatar malisper avatar matthewwiese avatar montyanderson avatar nex3 avatar pierre-rouleau avatar qdzhang avatar rntz avatar rocketnia avatar shader avatar shawwn avatar shirriff avatar smihica avatar svetlyak40wt avatar twilightsentry avatar womble avatar zck avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

anarki's Issues

stuck at stderr in repl

i suppose this could've been intentional but it seems weird to me.

`~/git/arc$ arc.sh
Use (quit) or ^D to quit, (tl) to return here after an interrupt.
arc> (stdout)

output-port:stdout

arc> gobbledy-gook
Error: "reference to undefined identifier: _gobbledy-gook"
arc> (stdout)

output-port:stderr`

basically after an error stdout goes to stderr and stays there

`(help for)` throws an error

I tried to use for the way Arc had it, and got a helpful error message:

arc> (for x 1 3 (prn x))
`for` has changed in anarki. See (help for) for more information.
  context...:
    for
   /home/zck/programs/arc/anarki/ac.scm:502:0: ac-call
   /home/zck/programs/arc/anarki/ac.scm:1222:0: arc-eval
   /home/zck/programs/arc/anarki/ac.scm:1275:4

So I tried to look at the documentation:

car: contract violation
  expected: pair?
  given: 'body
  context...:
   /home/zck/programs/arc/anarki/ac.scm:676:0: ar-denil-last
   /home/zck/programs/arc/anarki/ac.scm:811:10: len
   zz
    recur
   zz
   /home/zck/programs/arc/anarki/ac.scm:502:0: ac-call
   /home/zck/programs/arc/anarki/ac.scm:1275:4

Similarly:

arc> (help up)
car: contract violation
  expected: pair?
  given: 'body
  context...:
   /home/zck/programs/arc/anarki/ac.scm:811:10: len
   zz
    recur
   zz
   /home/zck/programs/arc/anarki/ac.scm:502:0: ac-call
   /home/zck/programs/arc/anarki/ac.scm:1275:4

Some other documentation works:

[mac] (def name parms . body)
Defines a new function called 'name'. When called, the function runs
'body', parameterizing 'parms' with call arguments.
For more information see the tutorial: http://ycombinator.com/arc/tut.txt
Or come ask questions at http://arclanguage.org/forum
nil
arc> (help +)
[fn]  (+)
+ is not documented.
nil

I don't know if this is related, but it seems similar. (type fn) doesn't work:

[sym] (fn params . body)
Creates an anonymous function. See the tutorial: http://ycombinator.com/arc/tut.txt
nil
arc> (type fn)  ;;this breaks
_fn: undefined;
 cannot reference an identifier before its definition
  in module: "/home/zck/programs/arc/anarki/ac.scm"
  context...:
   /home/zck/programs/arc/anarki/ac.scm:1275:4

I'm on version 4702cd2, committed in June. I'm using Racket 6.8.

error while starting up

Hi Ross, have you been running arc using arc.sh? It isn't working for me on OS X.

$ ./arc.sh
lifted.0.0: undefined;
 cannot reference an identifier before its definition
  in module: ac.scm
  context...:
   ac.scm:1295:0: aload1
   boot.scm: [running body]

The error message isn't very useful, but I did a binary search and narrowed it down to this line in ac.scm:

(require racket/random)

But I'm not sure how to fix it. Any ideas? Thanks.

Unable to create user in News

When creating any user in News, after pressing signup, the app navigates to http://localhost:8080/y and gives the following error in the arc REPL:

arc> rename-file-or-directory: cannot rename file or directory
  source path: /var/tmp/cooks.14569798801456979880387
  dest path: /home/pelle/anarki/www/cooks
  system error: Invalid cross-device link; errno=18
  context...:
   /home/pelle/anarki/ac.scm:1153:13: mvfile
    signup-handler
    respond
    handle-request-thread

Just tested: Creating user works fine in News on arc3.1 here, but fails in anarki with above error.

Dependency Mapping

It's very hard for me to tell what depends on what without leaving something out to see what breaks and even then it requires a lot of detective work. For example news.arc depends on app.arc, which in turn depends on srv.arc?

Does anyone have a good way or can anyone come up with a good(easy) way of mapping dependencies between .arc files or between the libraries?

List lookup behavior

Is there a reason list lookup fails ungracefully?

(= shortlist ("a" "b" "c"))
(shortlist 3)
arc> (shortlist 3)
list-ref: index reaches a non-pair
  index: 3
  in: '("a" "b" "c" . nil)
  context...:
   /Users/Kinnard/Desktop/anarki/ac.scm:977:33
   /Users/Kinnard/Desktop/anarki/ac.scm:1251:4

This is problematic for this sort of pattern:

$ arc ./buyicecream.arc
(case (argv 1)
   "vanilla" (pr "Good choice!")
   "chocolate" (pr "Great choice!")
               (pr "You must choose a flavor. Try again!")
 )

Which will throw an error like so:

list-ref: index too large for list
  index: 1
  in: '("icecream.arc")
  context...:
   /Users/Kinnard/Desktop/BitBox/anarki/ac.scm:977:33
   /Users/Kinnard/Desktop/BitBox/anarki/ac.scm:1267:0: aload1

Rather than executing the else-case. Why doesn't list lookup return a falsey value on failure?

Docker version

I know I made an OpenShift container for Arc a few years ago. Has anyone since done the same on Docker?

If so, we should include a reference as it might help for system-agnostic setup. Just "docker run arc"
If not I can volunteer to make one.

Wrong IP addresses when using reverse proxy

When running news.arcbehind a Nginx reverse proxy, news.arc thinks that every request is coming from 127.0.0.1. This may be more of an Nginx bug, but since a reverse proxy is needed for HTTPS, it should apply to any production instance of news.arc.

Example from my anarki/www/logs/news-2017-**-**,

1509768160 127.0.0.1 nil item 706
1509826295 127.0.0.1 nil item 821

This may not be a big issue, but it could break the IP blocking used against spam. It would be good to include a well-working Nginx configuration file in this repository, if anyone has one that works.

Scribd links on PDF-files

In news.arc submissions with links to pdf-files have links to viewing on Scribd. What is the use case for this functionality? JavaScript-capable browsers like Chromium and Firefox can already read PDFs.

Wouldn't it be reasonable to disable it by default, or have a clear option to disable it? Is this Scribd not a bit like Pocket in Firefox or Amazon Search in Ubuntu, in that it connects to 3rd party and is enabled by default?

I can probably submit a patch, if it is agreeable to disable it by default.

Nested Tables in arc

What's the best (or even a good) way to build nested tables in arc?
For example in Javascript this is pretty straightforward:

var pg = {
    name:"Paul Graham",
    age:55,
    hometown: "Weymouth, Dorset"
};
var jfk = {
    name:"John Kennedy",
    age:93,
    hometown: "Boston, Massuchussets"
};
var people = {pg, jfk};
console.log(people.pg.hometown); // Weymouth, Dorset

I'm having quite a bit of trouble doing something analogous in arc.

defextend ruins sig*

We have some cool functionality to get the signature of a function, right?

arc> (def say-something (thing) (prn "I got a thing: " thing))
#<procedure: say-something>
arc> (say-something 'pants)
I got a thing: pants
"I got a thing: "
arc> sig*!say-something
(thing)

Cool! But if we use defextend, it makes the value stored in sig* based off the way the defextend is done:

arc> (defextend say-something (thing) (number thing) (prn thing " is a number! Its root is " (sqrt thing)))
#<procedure: say-something>
arc> (say-something 3)
3 is a number! Its root is 1.7320508075688772
3
arc> sig*!say-something
allargs7466

sig*!say-something is no longer useful for anything defextended. This happens for the built-in methods find, some, cut, map, and more.

Blog posts not loaded

When the blog is started as part of news.arc, previous blog posts are not being loaded.

Error when accessing blog archive

When accessing the blog archive at http://localhost:8080/archive, I get the following error,

Can't coerce  nil fn
  context...:
   /home/pelle/anarki/ac.scm:1026:0: ar-coerce
    g20313
    recur
    g20313
    g20312
    handle-request-thread
   [repeats 1 more time]

It looks like the blog is being displayed correctly, except that there's a โ€ข too many.

How is data stored?

I obviously don't understand Arc-lisp. But I was wondering how data was stored. It seems like it's plain text files. How does Hacker News behave so well with simple text files?

Also how does it scale this data... can a single server handle all of the files opening and writing? Even if some data is in RAM it must eat a lot of RAM... so my question is, how does Hacker News continue to scale data with the huge amount of traffic they get? Where's the secret?

Unable to create blog user

When attempting to a user from, upon pressing signup, the app navigates to http://localhost:8080/y and gives the following error in the arc REPL:

_ranked-stories*: undefined;
 cannot reference undefined identifier
  context...:
    recur
Type: unknown type #<path:/var/folders/95/9ty0c4jd2x1_vv_t3dwndsxh0000gn/T/shash.14570218371457021837209>
  context...:
   /Users/Kinnard/Desktop/anarki/ac.scm:1002:0: ar-coerce
   /Users/Kinnard/Desktop/anarki/ac.scm:752:8: +
    shash
    shash
    set-pw
    set-pw
    create-acct
    signup-handler
    respond
    handle-request-thread
    handle-request-thread

I'm guessing this is related to #36

Only a limited number of submissions show up in news.arc

At the bottom of the front page of a running news.arc instance, there is a More link that navigates to the next page. However, on that next page the More button is not present, even when there are enough submissions to fill many pages.

`readall` stops prematurely if a top-level element is `nil`

Tested on commit e871d680cce6ed604aa8040ae51377f7e586971f. This bug is also present in Arc 3.1.

arc> (readall "1 2 () 4")
(1 2)

I expected '(1 2 nil 4). Similarly:

arc> (readall "1 2 nil 4")
(1 2)

Also I expected '(1 2 nil 4). readall works as expected when the nil isn't at top-level:

arc> (readall "1 2 (()) 4")
(1 2 (()) 4)
arc> (readall "1 2 (nil) 4")
(1 2 (nil) 4)

Error when running ./arc.sh

I get this error when I run $ ./arc.sh:

readlink: illegal option -- f
usage: readlink [-n] [file ...]
./arc.sh: line 12: mzscheme: command not found
./arc.sh: line 24: mzscheme: command not found
./arc.sh: line 40: [: =: unary operator expected
rlwrap: error: Cannot execute mzscheme: No such file or director

Error when running ./arc

When I $ ./arc per the README instruction I get this error:
$ ./arc: line 76: rlwrap: command not found

I am running OS X and I installed racket via homebrew if that's relevant.

case-sensitive field header matching in parseheader

I noticed a bug when I tried to login to Hackernews with the Lynx web browser. My browser sent the following POST request:

"""
POST /y HTTP/1.1
Host: news.ycombinator.com
[snip]
Content-length: 37

fnid=blah&u=jazzyb&p=********
"""

The server returned the error message, "Post request without Content-Length."

Doing some diving into the code I discovered that the content-length value is grabbed from the header in file srv.arc, function parseheader with a line that matches against the string "Content-Length:". This is a case-sensitive match (notice the lower case "length" in the POST request), but the HTTP RFC (rfc2616 sec. 4.2) states that field headers should be case-insensitive.

I've recompiled my Lynx browser so that my client sends the server what it wants, but I thought I would mention the non-standard behavior. I recommend that all field header string matches in the server code be changed to case-insensitive matches.

Checking whether a variable is defined

Is it possible in arc to check whether a variable is defined?

Specifically, I'd like to run the karma function in blog.arc, only when karma is defined, in order for the blog to work fine on its own, but also to have a blog-threshold* value when blog loaded through news.arc.

Perhaps it could be a function called exists? or defined?
try...catch would also work, but right now arc is throwing an error when using an undefined variable.

'for' doesn't terminate

In the arc tutorial ( http://old.ycombinator.com/arc/tut.txt ) the for loop is expected to behave like this (and it does in arc-nu):

arc> (for i 1 10 
       (pr i " "))
1 2 3 4 5 6 7 8 9 10 nil

but in anarki it doesn't terminate:

arc> (for i 1 10 
       (pr i " "))
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 user break
context...:
recur
recur
recur

If it is intended behavior, maybe it should be listed in the CHANGES file?

Update Readme

I'm working on a pull request for the install instructions on the readme but I figured it was a good idea to ask around to see if anyone had any other improvements they thought were pertinent. So?

run-news killed

I set up anarki on ubuntu 14.04 32bit, behind nginx. It runs well most of the day, but the process got killed for no obvious reason. I've checked the wiki/forum and this doesn't seem a known issue. I'm not familiar with anarki debugging. I wonder if some one could shed some light on what might cause the following issue. I'm not sure if it's an anarki issue per se, it could be my nginx configuration or some other component. Just trying my luck here. Thanks in advance

./run-news 

.....

    recur
   zz
    g2534
    g1517
    handle-request-thread
    handle-request-thread
tcp-write: error writing
  system error: Broken pipe; errno=32
  context...:
   /usr/local/racket/collects/racket/private/map.rkt:26:19: loop
   /home/shawn/news.warmgogo.com/ac.scm:1477:0: ar-close
    handle-request-thread
tcp-write: error writing
  system error: Broken pipe; errno=32
  context...:
   /usr/local/racket/collects/racket/private/map.rkt:26:19: loop
   /home/shawn/news.warmgogo.com/ac.scm:1477:0: ar-close
    th1
./run-news: line 3:  7164 Killed                  ./arc lib/run-news.arc

Format of POST request arguments in web.arc

@huetsch & @brianru What's the correct format of the POST request args for post-url in web.arc

(def post-url (url args)
  (cdr (mkreq url args "POST")))
(def build-query (querystr querylist)
  (string querystr
          (and (nonblank querystr)
               querylist
               '&)
          (to-query-str querylist)))

(def to-query-str (querylist)
  (if querylist
    (joinstr (map [joinstr _ "="]
                  (map (fn ((k v))
                         (list k urlencode.v))
                       (pair:map [coerce _ 'string] querylist)))
             "&")))

https://github.com/arclanguage/anarki/blob/master/lib/web.arc

Access argv in arc?

Don't know if this is the right place to ask this sort of question but: How do you access the argv type object in arc?

Error messages under heavy load

Under heavy load, I get the following output repeatedly:

...
char-whitespace?: contract violation
  expected: char?
  given: #<eof>
  context...:
   /anarki/ac.scm:1262:4
   /anarki/ac.scm:1279:0: aload1

char-whitespace?: contract violation
  expected: char?
  given: #<eof>
  context...:
   /anarki/ac.scm:1247:0: trash-whitespace
   /anarki/ac.scm:1262:4
   /anarki/ac.scm:1279:0: aload1
...

Is there any way to run this non-interactively?

POST requests time out

I'm trying to send a file from the browser to the Arc server via a POST request. To test it, I am just sending from localhost to localhost. I have a simple HTML form sending the file to the server:

    <form  action="http://localhost:8080/helloworld" method="post" enctype="multipart/form-data">
            <input type="file" name="submission"></input>
            <input type="submit"></input>
    </form>

and I'm just printing the request from the Arc server:

(defop helloworld req (pr req))
(thread (asv))

With some files it fails with the browser just hanging and the console printing an error message:

srv thread took too long for ::1

The issue doesn't appear to be only about the size of the file, because this one file that's 50KB always fails, but this other file that's 116KB always succeeds. I notice that in ac.scm there's this variable called upload-limit*, but it appears to be set to ~30MB.

At one occasion the error message was slightly longer (maybe there's something useful about where it got stuck?):

    srv thread took too long for ::1
tcp-write: error writing
  system error: Broken pipe; errno=32
  context...:
   /home/pelle/arc/anarki/ac.scm:931:0: printwith
    map1
    pr
    prrn
    respond
    handle-request-thread
    handle-request-thread
tcp-write: error writing
  system error: Broken pipe; errno=32
  context...:
   /usr/share/racket/collects/racket/private/map.rkt:26:19: loop
   /home/pelle/arc/anarki/ac.scm:1485:0: ar-close
    handle-request-thread
tcp-write: error writing
  system error: Broken pipe; errno=32
  context...:
   /usr/share/racket/collects/racket/private/map.rkt:26:19: loop
   /home/pelle/arc/anarki/ac.scm:1485:0: ar-close
    th1

There's some talk about file uploads in Arc forum, but it's also concerning an interesting mix of Arc versions.

I'm just trying to get this working on vanilla Anarki. I also tried running the above code in Rainbow, but it doesn't even get the content of the file sent in the POST request, (((req 'args) 'submission) 'content).

I am not sure if I am doing something wrong here, or if there's something broken. Are there any good ideas for workarounds, if it is something that can't be fixed? (Using PHP for file uploads is not the answer I'm looking for here :-)

As a side note, of course I am planning to share these optional extensions to HackerNews when they're working well enough. Is it preferred to add these extensions to the lib folder or the extras?

spliceable-list.arc documentation

Spliceable Lists as defined in spliceable-list.arc aren't documented with examples anywhere, right?
Anyone have a good gist of their behavior? As a short-cut alternative to reading the library :) which I'm doing now . . .

Domain colors in news.arc

When running news.arc and logged in as admin, when having made a submission, it is possible to click the domain name of the link as written in grey, which causes this text to change colour, first to red, then blue, then back to grey.
Does anyone know what those colours mean? Is it documented anywhere?

Accessing Current Directory

The files.arc lib provides a pwd command. But how does it access the current-directory?

(def pwd ()
  " Returns the current directory. "
  ($ (path->string (current-directory))))

https://github.com/arclanguage/anarki/blob/master/lib/files.arc#L31

arc> current-directory
_current-directory: undefined;
 cannot reference an identifier before its definition
  in module: "/Users/Kinnard/Desktop/anarki/ac.scm"
  context...:
   /Users/Kinnard/Desktop/anarki/ac.scm:1251:4

lib/blog.arc not working

What is the blog supposed to look like? Is it in production anywhere? I'm guessing it's not supposed to look like what I'm seeing.

And I get this error when I visit http://localhost:8080/newpost:

_reassemble-args: undefined;
 cannot reference undefined identifier
  context...:
    g20213
    handle-request-thread
    handle-request-thread

Distinction between peekc and readc

What's the distinction between peekc and readc?

The documentation here implies that readc doesn't "leave the character for future reads": https://arclanguage.github.io/ref/io.html

This behavior doesn't seem to support that though:

arc> (= tesseract "squared square")
"squared square"
arc> (peekc (instring tesseract))
#\s
arc> (peekc (instring tesseract))
#\s
arc> (readc (instring tesseract))
#\s
arc> (readc (instring tesseract))
#\s

Reading in files as strings

It's not clear to me from the I/O documentation how to read files in as strings. As yet I'm working with

(each f (dir ($ (path->string (current-directory))))
    (unless (dir-exists f) (= (files f) (readfile f))))

But that throws an error when attempting to read in non-lisp files. My guess is that that's because readfile is specifically for lisp files.

readc and readb don't seem to be intended for reading in files and both throw errors.

What's a good way to read in an arbitrary type of file?

expects type <number> as 2nd argument, given: 'nil; other arguments were: 1

-: expects type as 2nd argument, given: 'nil; other arguments were: 1

=== context ===
topstories
retrieve
newspage
g3072
g2086
handle-request-thread

I run :

(load "lib/news.arc")
(thread (nsv 8008))

I submit a new story. and then

(quit)

Yes, i shut down the server.
Then i restart nsv:

(load "lib/news.arc")
(thread (nsv 8008))

And i got the errors above.

Behaviors of `load` and `require`

load, and require which depends on it, seem to load a file from the shell's current directory and not the directory of the file with the load or require command in it.

My guess is that this is because load is for getting things into the REPL environment.

Example:

~/Projects/NewProject/main.arc & ~/Projects/NewProject/commands.arc

(load "./commands.arc")
(case (argv1)
    "option1" (prn "You picked option1)
    "option2" (prn "You picked option2)
    (prn "pick an option")
)

$ pwd

/Users/Kinnard

$ ~/Desktop/anarki/arc ~/Projects/NewProject/main.arc option1

gives:

open-input-file: cannot open input file
path: /Users/Kinnard/commands.arc
system error: No such file or directory; errno=2
context...:
load
/Users/Kinnard/Desktop/anarki/ac.scm:1250:0: aload1

This seems to me like it might make sense for load(probably not) but definitely doesn't make sense for require which I'd guess by the name is for requiring dependencies.

The path of a dependency should be specified relative to the path of the file requiring it, no?

Adjoining to empty list

Is there any reason (adjoin ) doesn't work on the empty list whereas (push ) does?

arc> (= x (list))
nil
arc> (adjoin "joy" x)
("joy")
arc> x
nil

vs

arc> (= x (list))
nil
arc> (push "joy" x)
("joy")
arc> x
("joy")

Login form news.arc

Can't coerce #(tagged mac #<procedure: fnform>) fn

=== context ===
/var/www/an/data/locr/ac.scm:1005:0: ar-coerce
login-form
zz
g2228
g2003
handle-request-thread

I don;t know what to do! I have hard email as server root

May be some server chmod?

Future of Arc

Are there any big plans for the future of arc? Future releases? Future features?

append doesn't append

append doesn't append.

This is what append does in Racket,

> (append '(a b) '(c d))
'(a b c d)

That makes sense to me.

This is what append does in arc,

arc> (append '(a b) '(c d))
(c d)
arc> (help append)
[fn]  (append l tail)
append is not documented.

join does the job, though,

arc> (join '(a b) '(c d))
(a b c d)

What is the deal with append in arc?

Anarki hangs when trying to get the length of a particular string

This bug happens in Arc3.1 also. This code works fine, and returns 4087:

(len ">^^v^<>v<<<v<v^>>v^^^<v<>^^><^<<^vv>>>^<<^>><vv<<v^<^^><>>><>v<><>^^<^^^<><>>vv>vv>v<<^>v<>^>v<v^<>v>><>^v<<<<v^vv^><v>v^>>>vv>v^^^<^^<>>v<^^v<>^<vv^^<^><<>^>><^<>>><><vv><>v<<<><><>v><<>^^^^v>>^>^<v<<vv^^<v<^<^>^^v^^^^^v<><^v><<><^v^>v<<>^<>^^v^<>v<v^>v>^^<vv^v><^<>^v<><^><v^><><><<<<>^vv^>^vvvvv><><^<vv^v^v>v<<^<^^v^<>^<vv><v<v^v<<v<<^^>>^^^v^>v<><^vv<<^<>v<v><><v^^><v<>^^>^^>v^>^<<<<v><v<<>v><^v>^>><v^^<^>v<vvvv<>>>>>^v^^>v<v<^<vv>^>^vv^>vv^^v<<^<^^<>v>vv^v>><>>>v^>^>^^v<>^<v<<>^vv>v^<<v>v<<><v>^vvv<v<vvv^v<vv<v^^^>v><<^<>><v^^>^v^>>^v<^<><v<>>v^<>>v<>>v^^^><^>>vvvv>^v<^><<>>^<>^>vv><v<<>>^^>v^^^><^<<^^v>v<^<<>v>^^vvv^v^>v^<>^^<>v^v>v>v<v^>vv>^^v<>v>>^<>><>v>v^<<vvvv<vvv><v^<^>^v<>>^><v>><>^<v>v<v>vv^>>vvv<>v>v<v^>>^>>v<<>^<>^<>>>^v<<<^<^v>vv^>><<><v^>^v^^^v<>^^vv><>><>>^>v^<v<>v<>>^<<^v>^^^<>^v^><>v<<v>vv^>vv<<>>><<^v^<>v<vv>>>^^<>^><<^>vv>>^<<v^^vv<>>><v>v><^<v<<>>>^^<>>^<^v><>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^v>>><><><<v^<<<v^<^^><v^>v^^vv<v^<>>vv^<^v<>^v>>v^v>v<^^vv><>^v<<>v^<>v^>>v>vvv<^><><^^>^vv^>>v^>^<^^<><>><<>^^^><^v^v><<<><<^v^vv>v>><^>>><v^>v<v><><v^v<>v^^>>v<<>v>v<v<v<^^<><>v^^<>>v<^v<v>v<><v<v>^<<>v>vv^^<>>^^^<>^^>^v>v>>>^v^v><v^^<><v>^^v^v<^<^^><<v<^<^<>^<>><<>^>>^>^^><v><>v<><>><<<>>>>vv>>>^>>^v<^>v^^^v<<vv>><<<^<<<>>>>>^>vv<^v^<>^<v^>^v><v>vvv<>>>^v^^^v<<<<>>^^<vv<^<^^>^<>v<^<<<>><>>v<^<>^<vvv<^<>><><<v>^^^>^^<<v<v^>^^v^>><<^vv><v>^v>>^<v>v>^^>^v>^vvv<>v^v^^<><vv>vv^>>><>v<^><v<v^<><<<>^v>^v<<<^>^>^>v^v<<><vvv<<v^^<><v>^>>><vv>><v>>v^<vv>>vv<<^v^v<<><^v<vv>>>vv<>>>>^vv>v^<>vv>v^v<v^><v<^^^^^>vv<><<vvv^<v><^<vv><^^^vv^<>^^^^<^><^<>v^<v^v<<^v<<^^<>>^<v^^>>>vv<vvv<>v<<>><^vvv^<<^^<<>>>^<>>>v^^><>><<>><v^v>>>>>><>>><v^<<vvv^>v<>>v^<>vv<><^^^^v^<<^<v^vv><<^^>v<^vvv^v>>v>^>>v>^^><<v^<>v<>vv<^v^vv><v><<vv^v>>v^>>v<^^^>^><<v<>^><>v>>>vvv<v<vv<^>>^v<v>^<^^^^^v><>v><>v^v^v<v^vv^v>vvvv<>vv<<<vv<v<<>^<^>^^v^<<>^<v><^><v<v<><<>v^<<^<><vv>v<<^v>>^v<><v>^>>^^><>v^<^<vvv^>^>^<<<<>vv>^v^v<^^^<vv>><>^^<<v<^<^^>>>v^<>><>")

But if you put a single character on the end -- as far as I can tell, any character -- the REPL hangs. I've tried s, >, <, and a few more.

Note that it's not just that the string is long that causes this problem:

arc> (len (newstring 4088 #\a))
4088
arc> (len (newstring 40880 #\a))
40880

Arc module system

Starting from @rocketnia's comments atop ns.arc, what would it take to build a module system into arc?

@akkartik you said, "we tend to have a more liberal aesthetic for modularity in this community, preferring a single global namespace unless there's a strong reason for namespacing in a specific situation. So we prefer a "batteries included" style of software sharing that doesn't require a lot of
decentralized foraging for libraries."

Is this mostly because there's no central module/package registry or are there other reasons for wanting everything in a single global namespace? That seems unwieldy the more libraries there are.

Voting in browsers w/o JS

When voting in a browser, that doesn't support JavaScript, a blank page is shown, because the navigation is cancelled using JavaScript.

Permission denied; errno=13 on every request

HI!

I'm trying to run news.arc inside an Ubuntu 16.04 Docker container. I have everything set up and seems to be working, however after starting the server with run-news I get this response on every request to port 8080:

open-output-file: cannot open output file
  path: /anarki/www/logs/news-2016-11-06
  system error: Permission denied; errno=13
  context...:
    srvlog
    g13098
    g13097
    handle-request-thread
    handle-request-thread
open-output-file: cannot open output file
  path: /anarki/www/logs/srv-2016-11-06
  system error: Permission denied; errno=13
  context...:
    srvlog

I have checked permissions on www/ directory, and even tried chmoding to 777 the whole path, but the error persists.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.