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

Even CL's special keyword syntax doesn't save you from optional and keyword confusion:

  [1]> (defun test (a &optional (b 'b) (c 'c) &key (d 'd))
         (list a b c d))
  TEST
  [2]> (test 1 :d :e)
  (1 :D :E D)
Optional parameters always bind first in CL, and I believe dsb is written to mimic that behavior.

Having all parameters be keyword arguments as well might be interesting, but it wouldn't avoid optional/keyword confusion.

-----

1 point by are 6655 days ago | link

> Having all parameters be keyword arguments as well might be interesting, but it wouldn't avoid optional/keyword confusion.

Why not?

Let's say you have a function with 3 standard args followed by 2 opt args. So you have 5 args, all keyable on the symbol you give them in the def.

Let's further say that in a call to this function, I key the middle standard arg (#2 in the def) plus the first opt arg (#4 in the def) and also, I omit the second opt arg (#5 in the def). So, I'm supplying two standard args apart from the two args I'm keying. Then the function call parser would know, after identifying the 2 keyed args and matching them to positions #2 and #4 in the def, that the first non-key arg supplied corresponds to position #1 in the def, the second non-key arg supplied corresponds to position #3 in the def, and that an arg for position #5 in the def is missing, leading to the usage of the default value for this opt arg.

This would even work when you want to raise an error for a non-supplied, non-opt arg.

Wouldn't this work quite intuitively (keying an arg when calling a function "lifts it out" of the normal "vanillas then optionals" argument sequence, shortening that sequence, put keeping a well-defined order for it)? (You would need special syntax for keys in this proposal. My suggestion is a colon appended to the arg symbol, rather than prepended, like in CL.)

Can someone give a counterexample if they think this somehow wouldn't work?

&rest args are left as an exercise for the reader :-)

-----

1 point by eds 6655 days ago | link | parent | on: Help link has disappeared

Yeah, missing on Firefox on Windows.

-----


I am curious about the people who claim to use Arc as their primary language. Do they not have jobs or classes that force them to use other programming languages?

-----

4 points by tjr 6656 days ago | link

Well, pg is probably one of them... and some folks likely really are in a position to use whatever language they like.

My day job is avionics software verification, so I don't program much for my job, per se, but what programming I do, I could likely do in Arc, and no one would care, as it's just for internal use.

-----

4 points by almkglor 6656 days ago | link

what, me work? this ain't work, i'm just getting paid for my hobby! ^^

-----

5 points by cooldude127 6656 days ago | link

yes, there are those people who program purely for hobby.

-----

2 points by sacado 6656 days ago | link

I didn't vote up for Arc, but I actually used it at work most of the time for the last month. For what I'm working on, I am free to use whatever I want and Arc really rocks !

And I use it as a hobby, too...

-----


Yeah, same here. And what really scares me is that no one can see past the prison of Java, not even the professors.

I am trying to convert some of my friends over to the Lisp Way. Making a little progress, but most of my friends don't think they have time to learn Lisp on top of their other classes.

-----

7 points by kennytilton 6656 days ago | link

I have heard that even universities are held hostage by students who view college as merely job training, demanding courses in the languages business cannot see past.

Seems to me the unis should fight that fight, but there are a lot of unis in the US, they have to think about marketing, too.

Perhaps as the IT job market continues to shrink the masses will move on to something else and let the computer science departments go back to teaching algorithms.

-----

3 points by eds 6656 days ago | link

I haven't met many students that are set on learning Java and only Java (or insert other popular language of choice), mostly its just that they don't know anything better is out there. I have, however, met professors who hold very strong, and wildly incorrect views on Lisp (many of which probably haven't been accurate for 20 years or more). But how is a college freshman supposed to tell a guy with a PhD he is completely incorrect?

I've heard claims that they'll let me program in whatever language I want in upper division, but I have to wonder if that is true or not.

-----

3 points by kennytilton 6655 days ago | link

I am just telling you what I heard. From professors. At unis in England, come to think of it. Oh, and Brown, a top US school. Sad, I know. :(

-----

1 point by jcl 6653 days ago | link

IIRC, Brown has two introductory computer science tracks -- one that starts with Scheme and the other with Java, with the Scheme course recommended for majors. They've got one of the PLT Scheme implementors on faculty, too, so some of the advanced courses are Scheme-based, as well.

-----


The error seems to be in ac-qq1, line 209, which uses map to look at nested structures in a quasiquote.

  ((pair? x)
   (map (lambda (x) (ac-qq1 level x env)) x))
And apparently scheme's map can't handle dotted lists.

Unfortunately I don't scheme well enough to know if another primitive does what we want... Otherwise we'll have to write a new version of map for use by quasiquote. (Or rewrite quasiquote to not use map at all, but that might be more work.)

I could do this but happen to be a little busy right now. (I wouldn't mind if someone were to beat me to it.)

-----

4 points by mec 6656 days ago | link

Someone in an earlier thread of mine suggested this fix:

  ((pair? x)
   (cons (ac-qq1 level (car x) env) (ac-qq1 level (cdr x) env)))

-----

2 points by shlomif 6656 days ago | link

Thanks!

I applied the following patch eventually:

{{{{{{{{{ ((pair? x) - (map (lambda (x) (ac-qq1 level x env)) x)) + (let ((t (lambda (f) (ac-qq1 level (f x) env)))) + (cons (t car) (t cdr)))) }}}}}}}}}

-----

2 points by eds 6656 days ago | link

By the way, what is with the "{{{{{{{{{" and "<<<<<<<<" in your posts? (You can mark text as code by indenting it.)

-----

3 points by mec 6656 days ago | link

To use the auto code format add 2 newlines and the code indented by two spaces;

  like this

-----

2 points by shlomif 6656 days ago | link

Hi! Thanks for the tip.

I normally use "{{{" and "<<<<" as delimiteres in a plaintext . But obviously it doesn't work very well here, so I'll keep in mind to use indentation instead.

Thanks again.

-----

1 point by eds 6656 days ago | link | parent | on: Handling dotted lists

Just wondering what (~no current) does in join* . Can't you just use current as a boolean value?

-----

1 point by dido 6656 days ago | link

It's supposed to be a predicate for a non-nil atom. I just realize that could better be written as (~acons current) instead, given that (acons nil) is also nil.

-----

2 points by eds 6655 days ago | link

I was confused because (~no current) is just the same as current by itself, and I didn't realize you wanted to test for non-nil atoms. Obviously (~no current) isn't what you want, because it returns true for lists.

  arc> (~no nil)
  nil
  arc> (~no 'a)
  t
  arc> (~no '(1 2 3))
  t
But I don't think (~acons current) does what you want either. Because (acons nil) is nil, (~acons nil) is true.

  arc> (~acons nil)
  t
  arc> (~acons 'a)
  t
  arc> (~acons '(1 2 3))
  nil
I think (~alist current) returns true for non-nil atoms, because (alist nil) is true.

  arc> (~alist nil)
  nil
  arc> (~alist 'a)
  t
  arc> (~alist '(1 2 3))
  nil

-----

1 point by eds 6657 days ago | link | parent | on: Poll: What do you edit Arc code with ?

For some reason, auto-indentation doesn't work for me. And also, I can't use the REPL unless I start emacs in the directory where arc is. Any advice would be appreciated.

Perhaps you could give example pieces of a .emacs files?

-----

5 points by nex3 6657 days ago | link

My .emacs, as it relates to Arc:

  (autoload 'run-arc "inferior-arc" "Run an inferior Arc process, input and output via buffer *arc*." t)
  (autoload 'arc-mode "arc" "Major mode for editing Arc." t)
  (add-to-list 'auto-mode-alist '("\\.arc$" . arc-mode))
I also have arc.el and inferior-arc.el in my loadpath.

As for starting the REPL, inferior-arc.el assumes that there's an "arc" program in your path. I did this by adding a symlink pointing to my arc.sh, but you could also customize the arc-program-name variable.

-----

1 point by eds 6657 days ago | link

Thanks. It still doesn't auto-indent though...

And I'm on Windows so I can't use arc.sh :( ... I tried to make up for it by using arc-exe instead, but arc-exe won't load if it isn't in the same directory as ac.scm. (I think this is because the require-namespace isn't done at compile time like normal requires are.)

-----

1 point by nex3 6657 days ago | link

For auto-indenting: you are pressing tab, right?

You should be able to set up a simple CMD script to start Arc on Windows. I think. I don't actually know that much about Windows. At the very least, you can set arc-program-name to be a manual invocation of MzScheme.

-----

1 point by eds 6656 days ago | link

Oh, thats what you mean by auto-indenting. I was expecting it to act like lisp mode where it indents when I press enter (which would be nice to have if someone could manage it).

My problem so far is that when I try to load arc, because the current working directory is not the arc directory, even if it loads as.scm correctly, it can't load ac.scm or any *.arc files. I could set it up to load something like "mzscheme -mf C:\...\arc\as.scm" but I don't know how to make mzscheme look for other arc files in that directory as well.

-----

2 points by nex3 6656 days ago | link

The standard Emacs indentation behavior is to indent on TAB rather than newline. This is also the default for Lisp-mode, as far as I know. You can rebind this by setting RET to comment-indent-new-line, though.

You need to add some argument to mzscheme to get it to cd into the arc directory. Check the args passed in arc.sh.

-----

1 point by eds 6656 days ago | link

Ok, thanks. I hacked a batch file and put it in my PATH so I can start arc from emacs. (Setting arc-program-name failed because run-arc wouldn't respect the quotes around the executable name.)

-----

3 points by eds 6657 days ago | link | parent | on: How do I Run a Program?

On Anarki, arc-exe.scm can be used to execute files containing arc code, much like with conventional scripting languages.

If test.arc contains

  (prn "hello world!")
then on the command line you could type

  > mzc --exe arc arc-exe.scm
to create an standalone arc executable and

  > arc test.arc
  hello world!
to run test.arc through the arc executable you just made.

It might also be nice to have this feature in as.scm.

-----

2 points by shlomif 6656 days ago | link

"It might also be nice to have this feature in as.scm."

I added this feature to as.scm in git-wiki/Anarki about two days ago.

-----

2 points by tiglionabbit 6657 days ago | link

What about on a mac? I was just told that this works: mzscheme -m -f as.scm < myprogram.arc

-----

3 points by sacado 6657 days ago | link

It does work, but don't do that :) At least if you're generating, for example, very big lists : everything evaluated in your program will be displayed. If your code contains something like (= foo (range 1 1000000)), you'll somewhat regret it...

But, in many cases, that will work just fine, despite the noise generated by the repl. You can also do mzscheme -m -f as.scm < myprogram.arc >/dev/null to turn the whole output off (in case you don't need it at all).

-----

2 points by absz 6657 days ago | link

Or wrap your whole program in a (do ... t) block, which is what I do. No change in semantics, and everything works fine.

-----

3 points by eds 6657 days ago | link

I believe the mzc compiler works on mac. (I'm not talking about exe's in the Windows sense here.)

Yes, that works, if you don't mind command-line hacks.

-----

2 points by eds 6657 days ago | link | parent | on: Issues Regarding Lisp Adoption

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

Some parts of the article are pretty unfounded, but there are some fragments of truth among the rubble.

-----

4 points by eds 6658 days ago | link | parent | on: New: Polls

It seems that you can vote for multiple items in polls. I don't know if this is a bug or a feature... it just seemed somewhat odd. (Maybe the poller should be allowed to choose whether users can vote for multiple items or not.)

-----

8 points by pg 6658 days ago | link

It's deliberate. Later I'll add an option to make choices mutually exclusive.

-----

More