Arc Forumnew | comments | leaders | submit | thaddeus's commentslogin
7 points by thaddeus 6021 days ago | link | parent | on: Thank you pg and rtm!

If there's a vote on how awesome arc is - you've got mine. Thanks pg & rtm.

-----

3 points by thaddeus 6022 days ago | link | parent | on: Last call for Arc bugs

Not sure if you missed this one ?

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

I didn't see a reply so I am not sure if you decided these were bugs or not.

Thanks, T.

-----

4 points by pg 6022 days ago | link

For now I'm going to leave Windows ports as something for other people to do downstream if they want to. It should be pretty easy, and I don't want to do it myself because I don't have access to a Windows machine or understand anything about the OS.

-----

6 points by kens 6022 days ago | link

Currently, ensure-dir and date use system to run Unix commands. It would be much more portable if they used mzscheme operations instead. This has caused me trouble not only on Windows, but different versions of Linux. And I think make-temporary-file could replace /dev/urandom.

-----

3 points by pg 6020 days ago | link

I changed date to get the date from Mzscheme, but it's not so easy to change ensure-dir. Mz's make-directory doesn't create intermediate directories like mkdir -p, and I don't want to get into trying to understand pathnames.

-----

2 points by thaddeus 6020 days ago | link

------------------------ In ac.scm

    1. added:
    (require (lib "file.ss"))


    2. added:
    (xdef 'make-directory make-directory)
    (xdef 'make-directory* make-directory*)
------------------------ In arc.arc (got from anarki)

    (def mkdir (path (o parents))
         (if (is parents nil)
             (make-directory path)
             (make-directory* path))
    )

    (def ensure-dir (path)
        (unless (dir-exists path)
             (mkdir path t)))
       
I tested on Windows... (ensure-dir "C:/thaddeus/arc/thaddeus/thaddeus/")

Edited. T.

-----

1 point by eds 6020 days ago | link

Here are the two patches for ensure-dir in Anarki stable:

http://github.com/nex3/arc/commit/111fa3c8f021c4abffc1526c88...

http://github.com/nex3/arc/commit/e4ba31f34f84cd946403541ca8...

According to the comment, there is a bug in MzScheme <371 which sets the sticky bit on *nix, so it may still be necessary to call system sometimes.

-----

1 point by thaddeus 6020 days ago | link

don't forget these changes require mods for the $ usage (which you can probably cut out)

and (xdef 'which-os system-type).

T.

-----

1 point by CatDancer 6020 days ago | link

Oh right, now I remember the sticky bit problem! http://arclanguage.org/item?id=2716

. . . .

-----

1 point by CatDancer 6020 days ago | link

If someone wants to implement this, make-directory* in the file.ss library (http://download.plt-scheme.org/doc/352/html/mzlib/mzlib-Z-H-...) looks like it might do it for you. But I haven't tried it myself (I'm not running Windows either).

-----

2 points by CatDancer 6022 days ago | link

If anyone wants to take on being a distributor for a Windows port (or for different variants of Linux, for that matter), I do have a patch for date here: http://catdancer.github.com/date.html

-----

2 points by eds 6021 days ago | link

Another option is the Anarki stable branch (http://github.com/nex3/arc/commits/stable/), which has most of fixes necessary to make most of Arc work portably on Windows and other OSes. (And, being a bug-fix branch, the amount of other random material is limited.)

-----

4 points by thaddeus 6021 days ago | link

I agree with the option, but I also think these posts will fall off the deep end in about 2 months. By then new members may only discover the option after they've discovered the problem. So we're not really saving new members wasted efforts unless the install page guides people.

T.

-----

2 points by pmarin 6021 days ago | link

Why not to setup some kind of wiki under arcelanguage.org? The Tclers Wiki is a great example. http://wiki.tcl.tk/

-----

1 point by eds 6021 days ago | link

pg: Even if you'd rather not think about supporting Windows portability yourself, providing a link to the Anarki stable branch would help new Windows users. Finding this stuff on the forum after it's fallen off the top couple of pages is not very easy.

-----

2 points by thaddeus 6022 days ago | link

Ok.

I have most of them already fixed myself, with the exception of pipe-from, but an average person (aka me) with Windows OS is going to spend time both trying to get Arc working and sifting through the forum which isnt easily searchable (I had to sift through over 300 posts, with 80% of the content being way over my head, to determine pipe-from wasn't expected to be working for a specific reason.... had no clue what "dev/urandom" even was).

If I might suggest: if your not going to fix these that you start a known issues document to save people from the headaches and tail chasing. Even putting something on your install page noting that Windows isn't supported would be appreciated by newcomers.

[Edit] As an idea maybe we could have one posting thread for OS related issues that your install page has a link to ? ....

T.

-----


I like what you've done, but I don't believe this will catch many of the other common conflicts. Example: names, global or table names and also dynamically generated versions of both - I've come across a few of these too.

I am under the impression that a language community led by original authors create something similar to anarki with a board or group that manages some form of standards, quality and compliance ect... similar to what I imagine scheme or python has. This way it's not the authors responsibility, but can be the communities too. I just think arc needs to establish itself with a bigger community and until then it's going to be a little more painful (a little less with your new hack).

Kinda sucks, no big community = a bit of a disincentive for hackers like yourself to contribute valuable code to the community if you end up getting all kinds of requests/baggage from it.

Probably not uncommon even in other languages.

T.

-----

2 points by CatDancer 6029 days ago | link

I don't believe this will catch many of the other common conflicts

Doesn't need to. This is one tool in the toolbag which does nothing but fix one problem. If you have a different problem, pull out a different tool :-)

board or group that manages some form of standards, quality and compliance

Sure, that's what's usually done, but it also has a lot of overhead in bureaucracy, politics, and conformance to poorly designed standards. I'm curious about another approach: what if patches were really easy? What if you could say, "ok, here are the fifteen patches I want in my Arc", and you could just push a button to get them? Now you don't need a board to be filtering patches for you, you can choose which ones you find to be of high quality. Or perhaps, for a particular project, a patch of terrible quality but happens to do something you want for that project :) I'm not sure of all the details yet, but I'm playing around with it.

disincentive for hackers like yourself to contribute valuable code to the community if you end up getting all kinds of requests/baggage from it

Well, my goal is to make it easy for me to share my Arc hacks. I have a whole bunch of hacks to Arc that I've written while doing my own programming, and some of them I've had the time to write up and publish. I'd like to make this easier and faster, so that I can publish more of my hacks without it being any trouble.

And I'd like to become easy for programmers such as yourself to publish your own hacks, such as the patches you made to the JSON library. That way if someone finds your version to be better, they can use yours. Or if they don't like what you did with symbols or something, they can use mine. Or pull out what changes they like from yours.

Now I'm not so worried about requests and stuff. If you see a way to make one of my hacks better, go ahead and publish your changes. No one is forced to use your version, but if it is better, then people can use it.

Eventually we have a lot of hacks floating around and people will start publishing collections. "Here are the thirty Arc hacks and libraries that I recommend". Each person who publishes a collection will have their own standards for what hacks they include. To get started, you can pick a collection author who has standards you agree with to get your initial collection of Arc hacks and libraries. But the collection still consists of individual hacks that you can pick and choose from, so you're not stuck with the collection compiler's decisions. That's the idea anyway... I still need to write up more about it.

-----

2 points by conanite 6028 days ago | link

So we'll have arc distros like we have linux distros today?

It might even work :))

btw it's impressive how simple the patch is ... a dozen lines, wow.

-----

4 points by CatDancer 6028 days ago | link

btw it's impressive how simple the patch is ... a dozen lines, wow

Yes, I'm coming to realize that a corollary to pg's hypothesis that succinctness is power is that succinct software is simple to extend! :-)

-----


This will work:

    (mac forstep (v start end step . body)
        (w/uniq (gi gm)
	    (case (isnt step 0) 
              t (if (> start end)
                    `(with (,v nil ,gi ,start ,gm (- ,end (abs ,step)))
                       (loop (set ,v ,gi) (>= (- ,v (abs ,step)) ,gm) (set ,v (- ,v (abs ,step)))
                         ,@body))
                    `(with (,v nil ,gi ,start ,gm (+ ,end (abs ,step)))
                       (loop (set ,v ,gi) (<= (+ ,v (abs ,step)) ,gm) (set ,v (+ ,v (abs ,step)))
	                ,@body)))
                      nil)))
Test cases: (some input cases are just to make sure there are no infinite runs)....

    (forstep i 5 10 1 (prn i)) 
    (forstep i 5 10 2 (prn i))
    (forstep i 10 5 2 (prn i))
    (forstep i 5 10 -2 (prn i))
    (forstep i 0 1 0 (prn i))
    (forstep i 1 0 0 (prn i))
    (forstep i -2 2 1 (prn i))
    (forstep i 2 -2 1 (prn i))
    (forstep i -4 2 2 (prn i))
    (forstep i -4 2 -2 (prn i))
    (forstep i 4 -2 -2 (prn i))
    (forstep i 4 -2 2 (prn i))

That being said, I don't understand why changing 'for' this way would create problems for you, or why you want (for i 1 0 (prn i)) to return nil.

also, I still think it would be nice for arc to support keyword arguments (hint, hint pg - though he's probably not reading this), then I could have 'step' as an optional arg with a default. i.e....

    (mac for (v start end (o step 1)  . body)...

    could allow:

    (for i 20 5 (prn i)) and also something like: (for i 20 5 step:2 (prn i))
T.

-----

1 point by skenney26 6030 days ago | link

Here's an alternative version of a step macro:

  (mac step (v init end by . body)
    (w/uniq (gi ge gtest gupdate)
     `(withs (,v nil ,gi ,init ,ge ,end
              ,gtest   (if (< ,gi ,ge) <= >=)
              ,gupdate (if (< ,gi ,ge) + -))
        (loop (set ,v ,gi)
              (,gtest ,v ,ge)
              (set ,v (,gupdate ,v ,by))
          ,@body))))

-----

1 point by thaddeus 6029 days ago | link

A much better alternate version too. The redundant code in my hacked version was obvious and ugly, but I struggled reducing it to a simpler form... Thanks!

I made a few slight adjustments though, as it failed 2 of my test cases (however unlikely they are to occur, infinite runs scare me).

    (mac step (v init end by . body)
     (if (isnt by 0) 
       (w/uniq (gi ge gtest gupdate)
        `(withs (,v nil ,gi ,init ,ge ,end
                 ,gtest   (if (< ,gi ,ge) <= >=)
                 ,gupdate (if (< ,gi ,ge) + -))
           (loop (set ,v ,gi)
                 (,gtest ,v ,ge)
                 (set ,v (,gupdate ,v (abs ,by)))
             ,@body))) nil ))
now passes these two test cases:

    (step i 5 10 -2 (prn i))
    (step i 0 1 0 (prn i))
Thanks! T.

-----

1 point by CatDancer 6031 days ago | link

That being said, I don't understand why changing 'for' this way would create problems for you

Perhaps I'm doing i from 1 to the number of things I have, and sometimes I have zero things.

Actually though it was a bit silly of me to suggest "forstep" when your version of "for" was doing what you wanted it to do. It's not a version that I'd want to use in my code, but that's no reason for you not to have your version.

-----

1 point by thaddeus 6031 days ago | link

ahh, I see. gotcha. T.

-----

3 points by thaddeus 6031 days ago | link | parent | on: Request for Bugs

I am not sure if it's a bug in arc that 'for' does not handle the reverse order or if it was never intended to work this way.

    arc> (for i 28 23
             (prn i))
    nil
http://arclanguage.org/item?id=9192

T.

-----

3 points by pg 6023 days ago | link

It wasn't intended to, but I'd considering broadening the def. I'll look at the hn source to see how often I'd use this.

-----

1 point by thaddeus 6023 days ago | link

As a note - It may still be a good idea, but I care less after some thought:

Originally I was trying grab the last number of items in a table (something similar to your code in prompt.arc where you are grabbing/printing the last n items passed into the repl).

When using a list, as you had, we can easily grab the last 'n' items in the list since lists maintain order.

    (= records* (list "record 1 text" "record 2 text" "record 3 text" "record 4 text" "record 5 text" "record 6 text"))

    (def lastn (n nlist)
      (firstn n (rev nlist)))

    arc>(each record (lastn 3 records*)
      (prn record)) 

    record 6 text
    record 5 text
    record 4 text
However if storing the data in a table it's not as clear grabbing the last n items since tables have no inherent order. as you can see this isn't as straight forward:

    (= records* (obj 1 "record 1 text" 2 "record 2 text" 3 "record 3 text" 4 "record 4 text" 5 "record 5 text" 6 "record 6 text"))

    arc> (each record (firstn 3 (sort > (keys records*)))
         (prn (records* record)))

    record 6 text
    record 5 text
    record 4 text
so I had hoped 'for' in reverse would be cleaner...

    arc> (for i (len records*)(- (len records*) 3)
          (prn (records* i)))

    record 6 text
    record 5 text
    record 4 text
    record 3 text
only after re-writing I noticed that I was getting too many results thus ended up having to hack:

    arc> (for i (len records*)(- (len records*) 2) 0
          (prn (records* i)))
If my hope was to make the code more readable, it didn't work.

So.... instead I wrote 'grab':

    (def lastn (n nlist)
      (firstn n (rev nlist)))

    (def grab (which n them (o sop nil))
	 (case (type them)
	        table (case which first (if (no sop) (firstn n (sort < (keys them)))(firstn n (sort sop (keys them))))
	                          last  (if (no sop) (firstn n (sort > (keys them)))(firstn n (sort sop (keys them)))))
	        cons  (case which first (if (no sop) (firstn n them)(firstn n (sort sop them))) 
	                          last  (if (no sop) (lastn n them) (lastn n (sort sop them))))))
	
And now I feel it's much more readable + works on both lists and tables:

    arc>(each record (grab 'last 3 records*)
        (prn (records* record)))

    record 6 text
    record 5 text
    record 4 text
T.

[EDIT] - Hadn't thought about it until now, but it has re-use even if the table doesn't have nums for keys, it would also work on other keys (example grabbing the last n items of alphabetical order). Anyway... don't spend time on re-working 'for' it it doesn't help anyone else.....

-----


thank you too.

-----


I see, thanks.

and... I agree, I just start using globals to start then after I have it working I change 'em (bad habit).

    (defop test req
	   (let parm (arg req "parm")
	   (prn parm)
	   (br)	
           (if (is parm nil)
	       (do-it "test" url parm))   
               (do-it (string "test?parm=" parm) parm)    
    ))

    (def do-it (url parm)  
        (form url (gentag input type 'hidden name 'parm   value parm)
        (textarea "stuff" 10 50)
        (br)(submit))
    )
Works like a charm!

:)

T.

-----


This could be the same issue I was looking into here...

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

, but isn't this a bug in arc ? this can't be by design, correct ?

T.

-----

5 points by thaddeus 6034 days ago | link | parent | on: Request for Bugs

Anarki has a lot of great stuff in it, but it also has alot of crap in it. I spent 2 weeks just going through the code pulling out the pieces I like from Anarki and not the rest. I certainly hope pg keeps the arc code down to the dozen or so core files forcing the community to build libraries on top rather than integrate adhoc extras at such a low level that it's brutal to separate the good from the bad.

-----

2 points by thaddeus 6036 days ago | link | parent | on: Request for Bugs

I am not sure if this is a bug or by design, but I will throw it out there. Records stored in tables are not returned in the original order they were loaded (unlike lists are). It would be nice to iterate/process records in the table without having to create code to store the original loaded order.

Further to order type issues shouldn't the 'accum' function return the list of items in the order in which it was accumulated ? Currently it returns the reversed order. it would be nice for this to work as one would expect.

Please and Thanks, T.

-----

3 points by pg 6023 days ago | link

It's intentional. You have to use an explicit rev if you care about the order-- since sometimes you might not. But I'm open to changing that, because I'm often annoyed to have to add the explicit rev. (This is why you have to write apps in a language at the same time you're working on it.)

-----

2 points by CatDancer 6023 days ago | link

I use rev:accum often enough that I'd use an operator that did that (whether it was called accum or something else).

-----

5 points by pg 6023 days ago | link

Ok, I just changed accum to do the rev.

-----

1 point by thaddeus 6023 days ago | link

thanks. T.

-----

More