Arc Forumnew | comments | leaders | submit | lark's commentslogin

Well, I'm incompetent, but this works:

  ;; write in a fine file                                                                                                 
  (def wiff (file contents)
       (w/outfile p file (each b contents (writec b p))))

-----


I still get the same error. Hmm.

I don't get the error if I call errsafe:temload before the (asv) call.

I don't get the error if I call errsafe:temload within a defop.

I don't get the error if I call errsafe:temload from a def called by a defop.

But I still get the error in the code I'm running right now. I'm confused now.

-----

1 point by akkartik 4891 days ago | link

Just thinking aloud: is there another temload in your code? Is some other function besides temload trying to open that file?

Feel free to paste in a full sample session.

-----

1 point by lark 4897 days ago | link | parent | on: Why do I get a non-mutable hash-table?

Can I persist and read back a #hash that contains a #hash?

Alternatively, can I persist and read back a list of hash tables?

-----

1 point by akkartik 4897 days ago | link

Yeah I have those in my repo. Look for serialize in the link in my profile.

I'll add it to anarki later today.

Update: I just found myself complaining about this nearly 3 years ago, along with an implementation: http://arclanguage.org/item?id=10677. Not as clean as serialize, though.

Update 2: Ok, now read and write work with nested tables. You can read the output of write:

  arc> (= h (w/instring f (tostring (write (obj a 1 b (obj c 3 d 4)))) read.f))
  #hash((a . 1) (b . #hash((c . 3) (d . 4))))
And you can modify the results:

  arc> (= h!c 34) ; modify outer table
  arc> h
  #hash((c . 34) (a . 1) (b . #hash((c . 3) (d . 4))))

  arc> (= h!b!e 34) ; modify inner table
  arc> h
  #hash((c . 34) (a . 1) (b . #hash((c . 3) (e . 34) (d . 4))))
http://github.com/nex3/arc/commit/547d8966de

-----

1 point by lark 4903 days ago | link | parent | on: How do I upload files in Arc?

To use webupload.arc, one needs to first include aform-multi (and the enctype attribute) from Anarki into Arc 3.1.

Then, uploading a 679k file reports the following in the repl output:

  Can't coerce "S?" int
Uploading a 23-byte file reports the following into the repl:

  >: expects type <real number> as 1st argument, given: nil; other arguments were: 0

and the following on the webpage output:

  ... headers ... 
  Content-Type: nil 
  Content-Length: nil 
  ... more headers ... 

So it doesn't work. There's no clen in the request deftem, and that requires modifying srv.arc

It seems the proposition is to use Anarki in its entirety, rather than Arc. What are the implications?

-----

1 point by akkartik 4903 days ago | link

Hmm, are you able to get webupload.arc to work in just anarki?

-----

1 point by lark 4901 days ago | link

Running anarki with mzscheme 372 does not work. Starting anarki with pg's instructions reports:

  require: unknown module: racket/unsafe/ops
Installing the latest racket 5.2.1 to work with anarki is causing trouble too. I see the following (which had no resolution): http://arclanguage.org/item?id=12146

...but in my local dir ~/racket. Basically:

  ~/racket/bin$ ./racket 
  -bash: ./racket: No such file or directory
Trying to start plain anarki also causes trouble:

  $ ./arc.sh 
  ./arc.sh: line 7: type: rlwrap: not found
  ./arc.sh: line 11: /home/akkartik/racket/bin/racket: No such file or directory

  $ ls -lrtah /home/akkartik/racket/bin/racket
  -rwxr-xr-x 1 rouge rouge 3.4M Feb  2 08:48 /home/akkartik/racket/bin/racket

Is it possible to tell anarki which mzscheme to use?

-----

1 point by akkartik 4901 days ago | link

Yes, you need to run anarki with racket. I typically simply install racket, clone anarki, cd into that dir, and then run:

  $ racket -f as.scm
Does that work for you?

---

"bash: ./racket: No such file or directory"

Weird indeed. What do you get if you type this in?

  $ file `which racket`
What version of linux or macos are you on? (If you're on windows that's beyond my experience.)

---

I just searched anarki and I don't seem to have leaked my homedir in the scripts or anything like that. Did you deliberately create that /home/akkartik directory?

-----

1 point by lark 4901 days ago | link

It doesn't work. racket doesn't run

  $ racket -f as.scm 
  -bash: racket: command not found
---

  $ file `which racket`
  /home/akkartik/racket/bin/racket: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
---

Yes, I'm using it as an example of my home directory name. Bad example it seems.

---

I have a 4.2.1 mzscheme, and that reports:

  $ mzscheme -f as.scm 
  ac.scm:1323:9: racket/unsafe/ops: standard-module-name-resolver: collection not found: #<path:racket/unsafe> in any of: (#<path:/home/lark/.plt-scheme/4.2.1/collects> #<path:/usr/lib/plt/collects>) in: racket/unsafe/ops

-----

1 point by akkartik 4901 days ago | link

Thanks for that info. Yeah it may not work with mzscheme because that's a legacy language.

Can you tell me what version of linux you're using?

All my servers are 32-bit linux, so I'm not sure what's going on. Googling around, are any of the answers here useful?

http://superuser.com/questions/248512/why-do-i-get-command-n...

-----

1 point by lark 4901 days ago | link

I must be on a 32-bit linux.

  $ uname -m
  i686
All right, compiling racket...

Can I ask why anarki does not work with mzscheme 372? Arc works with it.

-----

1 point by akkartik 4901 days ago | link

I'm sure there's a 32-bit version you can download.

"Can I ask why anarki does not work with mzscheme 372? Arc works with it."

Yeah, I misspoke. I meant that I don't know if anarki works with mzscheme because I haven't tried it in forever and the default anarki instructions are to use racket.

I'm pretty sure it won't work with v372, that's a really old version. I believe pairs used to be mutable by default back then. Or perhaps they were immutable, but that was a big transition and I'm sure there were bugfixes.

And if you're going to install a more recent version of racket, might as well just run racket since it gets the most eyeballs on bugs. The community seems to have converged on racket as well. Testing resources are scarce; easier to just focus on one configuration.

BTW, are you aware of the wiki? http://sites.google.com/site/arclanguagewiki

-----

1 point by lark 4901 days ago | link

There is a 32-bit version I can download -- just not for Debian.

Building from source gets me to:

... raco setup: 0 making: tests/mzcom raco setup: 0 making: tests/match Racket virtual machine has run out of memory; aborting

Enough.

-----

1 point by akkartik 4901 days ago | link

That's too bad. My commiserations.

Edit: Hmm, I run mint which is based on debian. What am I doing? I think I just downloaded the ubuntu version. It's not like it's a real deb and installs in system dirs anyway.

-----

1 point by lark 4900 days ago | link

Oh you legacy programs, you'll be the death of me.

-----

1 point by akkartik 4900 days ago | link

Did installing the ubuntu version of racket work?

-----

2 points by lark 4897 days ago | link

Anarki runs now, found a package. Thanks for the help.

-----

1 point by akkartik 4897 days ago | link

Awesome! Can you share more details?

-----

1 point by lark 4891 days ago | link

I installed racket 5.2.1+dfsg1-4 from Debian sid.

It makes Anarki start without problems.

-----


A related question: how can I connect to the repl and upgrade the app without killing the process?

-----

2 points by akkartik 4908 days ago | link

In general there's no way to do this, but you can simulate hot-swapping with thread and a little code organization. In readwarp.com, for example, I arrange the code so loading a file multiple times doesn't break behavior. Among other things it requires not reinitializing global variables, only functions. See http://arclanguage.org/item?id=11103, expecially tips 1 and 2.

-----

1 point by lark 4906 days ago | link

How would one hot-swap continuations?

-----

1 point by akkartik 4906 days ago | link

You mean like fnids? They're just data, so you should be able to reuse them as is. If you change the html for the frontpage old continuations to the next page may not reflect the change, but they'll gradually expire and get replaced with the updated versions.

-----

1 point by lark 4908 days ago | link | parent | on: Why do I get a non-mutable hash-table?

I'm wondering if I ran against some weird condition where a hash table passed as a parameter in a function makes itself immutable.

-----

1 point by akkartik 4908 days ago | link

Is there a set of steps that reliably shows this error?

-----

1 point by lark 4911 days ago | link | parent | on: What's the purpose of hook?

That answer has no conclusion though. I still don't see why one can't just call the function they want.

news.arc does not dynamically add and remove hooks, so the hook abstraction seems redundant. And the defhook macro is unused.

My conclusion is that hooks were something to experiment with originally, and later back away from.

-----

1 point by akkartik 4911 days ago | link

Another possibility is that hooks are prone to change and so weren't released.

-----

1 point by lark 4940 days ago | link | parent | on: How can I connect to MySQL with Arc?

It doesn't work.

Trying to load this file fails:

  Use (quit) to quit, (tl) to return here after an interrupt.
  arc> (load "mysql-ffi.arc")
  arc> Error: "reference to undefined identifier: _w/inline"

To be more clear, the complete code that makes MySQL work is nowhere to be found.

Before I posted this question, I went through these URLs and tried to put together their fragments with various errors.

-----

1 point by akkartik 4940 days ago | link

Yeah I'm not surprised it isn't working. We don't use a database with our arc programs, we just use flat files like HN does.

-----

1 point by lark 4940 days ago | link

Does anyone know where I can get the w/inline source?

Does anyone have the tiniest example of a working FFI?

-----

1 point by akkartik 4940 days ago | link

w/inline and the rest of the FFI is right there if you browse on github: http://github.com/nex3/arc/blob/arc2.master/ffi.arc

Do you need help downloading that (extremely old) version of arc from github?

-----

1 point by lark 4940 days ago | link

The following may be premature: based on what I managed to assemble so far, I now get:

  ffi.scm:4:6: let: bad syntax (not an identifier) at: (quote ffi-lib) in: (let ((nm (ac-global-name (quote (quote ffi-lib)))) ((quote ffi-lib) ffi-lib)) (namespace-set-variable-value! nm (quote ffi-lib)) (quote ffi-lib))

-----

1 point by akkartik 4939 days ago | link

Can you tell me what steps you followed to install arc?

-----

1 point by lark 4939 days ago | link

The usual steps from http://arclanguage.org/install

This is using Arc 3.1, not Arc 3, and with an mzScheme 3.7.2 built from source. Other Arc apps I've written work, and news.arc, blog.arc etc. work.

-----

1 point by kinleyd 4939 days ago | link

Why not use more current versions of MzScheme - see https://sites.google.com/site/arclanguagewiki/install-arc

-----

1 point by lark 4939 days ago | link

I was not aware of the instructions being out of date.

Still, the error I'm facing does not seem related to mzScheme.

-----

2 points by akkartik 4939 days ago | link

Here's what I've tried so far:

a) Install v372 from http://download.plt-scheme.org/v372.html on a debian linux laptop.

b) Run the shell script, install it to the directory containing the arc2.master branch.

c) Run:

  plt/bin/mzscheme --no-init-file --load as.scm
It seems to come up without errors and ffi.arc seems to be loading up.

(When you report errors it's usually much faster to tell people how to reproduce your error in this step by step manner. Then they can usually immediately look at the instructions and tell you what you're doing wrong without a lengthy back-and-forth.)

-----

1 point by lark 4939 days ago | link

Here's what I've tried and the outcome:

http://arclanguage.org/item?id=15723

-----

1 point by akkartik 4939 days ago | link

Can you try the steps I outlined and confirm that it works for you? Perhaps something's messed up about the version you're on. Once you have a working version we can go in and poke at the differences to see where the problem might be.

-----

1 point by lark 4939 days ago | link

I tried the steps and Arc comes up. So ffi.scm must be working.

-----

1 point by akkartik 4939 days ago | link

Great. Can you share a copy of the repo that isn't working? Maybe on github or something?

-----

1 point by lark 4937 days ago | link

I can't share a copy of the repo, but I'm going about introducing FFI the opposite way: pick Arc 3.1 and add any files that are needed to get just FFI and mysql-ffi.

That's the approach that leads into trouble.

-----

1 point by akkartik 4937 days ago | link

That's a good approach. Keep at it, I'm sure you'll figure it out.

One way to get help with it: describe simple step-by-step changes to the repo that cause errors. Download arc 3.1, add this file from here, type this in at the repl, etc. Don't forget the actual text of the error you see as well.

-----

1 point by lark 4939 days ago | link

Well, after extracting the code from that Git branch, I don't see anything related to "(quote ffi-lib)" that can be fixed/added/changed.

In short, FFI doesn't work.

-----

1 point by lark 4940 days ago | link

I do.

How can I download what that URL shows without lots of mouse-clicks?

The following brings down something that's different than what the URL shows:

  git clone https://github.com/nex3/arc.git

-----

2 points by akkartik 4939 days ago | link

Once you've cloned it:

  git checkout arc2.master

-----

1 point by lark 4939 days ago | link

Thanks.

That version of Arc doesn't work.

  $ ./arc.sh 
  Compiling arc.arc...
  call-with-input-file: cannot open input file: "/home/dark/nex3/arc/bell-style" (No such file or directory; errno=2)
  >

-----

1 point by lark 4995 days ago | link | parent | on: How do you make radiobuttons?

Anyone?

-----

1 point by lark 4996 days ago | link | parent | on: How do you make radiobuttons?

I think the following does it:

  (def radio (n v)
      (gentag input type 'radio name n value v))
Though I'm not sure how to set an initial selection. Or how to retrieve the value of the selected radio button.

-----

More