Arc Forumnew | comments | leaders | submit | ncommentslogin
211.
2 points by Fenng 4852 days ago | link | parent | on: Wrong comments time

Waiting for you ...

:)

212.
2 points by Mikechaos 4874 days ago | link | parent | on: Remove all duplicates from a list

Very interesting! Indeed, I had though about optional args (and that is what I had done first) but didn't want sort called at each rec. I like how you fixed it. Sort might be a bit obfuscated.. But I don't find it really bothering. It's use is straightforward and self explained!

As I see it, the dot (car.ls) is syntactic sugar for applying a one arg function? Pretty clever! It replaces really well the y, no doubt.

The differences are subtle, but it definitely feels better, my personal alarm gets a bit of rest.

Use of iso. Don't know why I used is.. Question I had, can '=' be use as a comparison operator?

Also I get your use of 'else, but not exactly sure how it passes. Does it count as an expression evaluated to true, so then (unique_list...) gets to be it's true clause/case? Or is is simply not counted at all (making (unique_list...) the false clause of (iso car.ls x). Not sure if I'm making my self clear here, so I'll try and rephrase a bit. A -> 'else gets to be an other if expression (if 'else) wich always evaluated to true -> following expression is the true clause of it. (what I think is happening) B -> 'else isn't counted as a full s-expr (not sure it's the right way of saying this) and so it just goes along with following (unique_list...) -> Makes it the false clause of (iso car.ls x) and not interpreted as an other if. (Then, I don't understand why!)

Finally, and that's really a bonus I'm asking, but since I'm looking into making my next side-project (wich could be a long-term project) in Arc-based lisp, it could get me closer, I'll ask it anyway. As of what I know, since PG's fully involved in YC, and so arc's development is in a semi-dead state, I'd better be at least looking at forks of it. Now, if I understood well, there are two major forks, one you are working on, that would be wart, and anarki (mistaken already?).

Would there be any difference in wart's implementation of the same alorigthm (since it shows a bit more use-case than pg's algorithm), or then, what would be wart's more natural form?

Thanks for the time! It's already more than I could ask!

213.
1 point by Mikechaos 4874 days ago | link | parent | on: Remove all duplicates from a list

Ah! No breaking bubble! I searched for it and couldn't get it (there is no complete doc about all pre built function in arc, out there, heh? You just gotta read the source on and on till you get them all, I guess (wich is, in definite, not a bad thing at all!)).

I actually wanted to re-write it using a hash but couldn't get right away the semantics and syntax they had. This is perfect, It'll get me to discover how they actually work.

Thanks for the tip! It'll render better :)

Though, for the sake of learning (I am, for sure, studying PG's version and learning from it), could anyone quickly comment my code cause and what bad practices I'm doing (I may be a newbie in Lisp, but I still feel when things aren't elegant!).

Thanks to all

214.
5 points by dcminter 4892 days ago | link | parent | on: Why Arc hasn't taken off

To answer your question about the chair - it's seating for a church or chapel. Prayer books and hymnals are kept in the pocket on the back for the use of the people in the row behind.
215.

Finally it works. I have decided to switch to nginx and with only few tweaks, I can now run on 80 port, the default port of nginx.

Here is the simple code to do that on etc/nginx/nginx.conf server { listen 80; server_name bloggervietnam.com www.bloggervietnam.com;

    location / {
    proxy_pass http://127.0.0.1:8080;

    }
Remember to put this code inside http tag otherwise it will cause error. You can check nginx configuration by typing : nginx -t and then restart nginx. It works!
216.

Thanks for your help thaddeus!

1. I just install screen and fortunately it works well. I just hit F6 button to detach my terminal session. That is why I removed fluxbox GUI for saving RAM and resource.

2. I follow the help above and now I can chance the color of the forum.

3. I have not solved the matter yet since apache did not work despite that I already installed necessary modules as you mentioned.

I may switch to nginx for a try. Thanks for your care again :-)

217.

Thanks for your help rocketia :-P. Here are some of my thoughts and experiences after following your guide.

1/ I often use WinSCP instead of PuTTY on Windows to control VPS. Of course, we can only interact/manage the virtual private server via commands line, but in the case WinSCP helps me to upload the files easily. I tried to use fluxbox (a lightweight GUI for Ubuntu) and VNC to remote connect the server and use the "original" terminal to run racket and ARC forum. As far as I tested, whenever I turn off terminator/SSH window on Windows, the ARC forum will turn off as well. So there is no other choice for me to run source code.

2. Thanks for your investigation, however, the color on the front page does not change from grey to yellow/orange like Hacker News or ARCforum. I found out that the <tag> is "bgcolor", not "border-color", so it will not run even you tweak the code on the top of news.arc file. I believe that we need to change the color of the forum by "dealing" with html.arc file. I got the tag bgcolor (line 86) in that file but not sure how to change.

3. One of the most problem with me right now is how to "forward" the default port on racket server from 8080 to 80 which is default port of Apache. When I tried to configure my httpd file inside apache2 according to this instruction http://nicholasblee.com/blog/hacker-news-clone-on-a-free-aws...

but it does not work. So that is the reason why I have to access the ARC forum by typing the port 8080, otherwise the apache will run the 80 port with a blank page.

Here is what I add to /etc/apache2/httpd.conf <VirtualHost :80>

ServerAdmin myaccount@gmail.com

DocumentRoot /var/www

ServerName bloggervietnam.bloggervietnam.com

<Directory /var/www >

Options FollowSymLinks

AllowOverride None

Order allow,deny

Allow from all

</Directory>

#configure cluster

<Proxy balancer://arc_cluster>

BalancerMember http://127.0.0.1:8080

</Proxy>

RewriteEngine On

#Redirect all non-static requests to the cluster (arc)

RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f

RewriteRule ^/(.)$ balancer://arc_cluster%{REQUEST_URI} [P,QSA,L]

ErrorLog logs/blogervietnam.bloggervietnam.com-error_log

CustomLog logs/bloggervietnam.bloggervietnam.com-access_log common

</VirtualHost>

When I tried to restart apache2 with sudo permission, it responded that:

Syntax error on line 27 of /etc/apache2/httpd.conf: BalancerMember Can't find "byrequests" 1b method. Action "configtest" failed.

Could you give me some piece of advices mate? Thanks you very much indeed!

218.

I'm not sure what you mean by error codes. C doesn't have built-in support for things like exceptions.

Method-chaining doesn't come into play, because, technically, there is no such thing as methods. Just regular functions.

Errors are typically indicated in the return value of some function. Error checking, then, is an if block following the function call.

219.

See above reply to Pauan.

There are other styles, but the differences aren't all that significant. I like K&R.

220.

The nice thing about indenting in C is simply that it falls out naturally, so you don't have to think about it.

I'm not proposing to turn Lisp into C. The formless nature of Lisp is essential to what enables it to do things you can't do in C.

221.

It's pretty rare that I don't have syntax highlighting. Another thing about the parens that is annoying is that there doesn't seem to be a single, canonical way for them to interact with indentation, like K&R style for C.

I haven't used ruby, but I think terseness and readability tend to go hand in hand, and ruby looks terse.

Having a sugar -> S-expressions transform is great. It's the best of both worlds.

222.

Thanks. Your language looks like one I'd like to try. Getting rid of the outermost set of parens is a good idea; the fewer parens that you have to balance, the better. I haven't tried doing any serious programming in a whitespace-sensitive language. I've always found C very readable -- I think C hit a syntactic sweet spot. A lot of people must agree, judging by how many languages have copied C's style.

PS. The one whitespace-sensitive language I use often is make, if it counts. I like make's syntax.

223.
2 points by ChristophRe 4943 days ago | link | parent | on: Map + question

Thank you, Pauan.

Ok. I did the mistake (missed to take the apply) not to apply it.

No it is clear. I learned from this mistakes.

Do you the word "mis-take

224.
3 points by iopq 4973 days ago | link | parent | on: The evolution of Nulan's : and ;

I would personally use something like | if it's not used for anything

it looks like an undirected paren so in cases like a |b| c it translates to a ((b) c) or (a (b)) c I guess I'd pick the first option (more natural for reading left to right), but for the order of operations it doesn't matter

225.
2 points by iopq 4974 days ago | link | parent | on: Dynamic languages are static languages

As a hammer, I feel that some objects that don't appear to be nails are actually just a worse kinds of nails that are harder to drive. In fact, they are a less useful subset of nails in general.
226.
2 points by iopq 4975 days ago | link | parent | on: The evolution of Nulan's : and ;

well, you already make whitespace significant by saying that alphabeta is not alpha beta

the real crux of the issue is whether it comes before an identifier or after don't think of it as whitespace disambiguating nobody says *pointer in C is "too significant whitespace" just because it can't be separated by a space (in which case it becomes multiply!)

227.
3 points by iopq 4978 days ago | link | parent | on: The evolution of Nulan's : and ;

why would you need two different characters?

foo; bar; qux ;corge (foo(bar(qux))corge

foo; something is foo(something)

something ;foo is something(foo)

228.
2 points by iopq 4979 days ago | link | parent | on: The evolution of Nulan's : and ;

What is the change? I hate parens in any language with a passion. I even suggested a similar approach to Newspeak (a language based on Smalltalk): https://groups.google.com/forum/?hl=en&fromgroups=#!topi...

of course here you can get away with just positional placement because all binary and keyword sends make it fairly clear where the message send is and where the argument is

229.
1 point by dehrenberg 4995 days ago | link | parent | on: Infix support in wart

APL and K are right-associative.
230.
1 point by dehrenberg 4996 days ago | link | parent | on: Infix support in wart

I really like this syntax. Getting rid of precedence is definitely good. (You can also go right-associative like K, which has its small advantages.) To me, the most interesting part is the way you make whitespace significant. It's a great idea that I haven't heard before. It could be tempting to make that more intricate, but that's probably more trouble than it's worth in practice.
231.

Thanks so much for all of your feedback Pauan!
232.

I just want to say thanks akkartik for your public writings about "apply" and first class macros - this allowed me to not go down the rabbit hole of figuring out what `(apply <macro> args)` ought to mean and concentrate on getting the Sudoku solver to work instead ;-)
233.

Thanks for the solid feedback Pauan (and akkartik!) with some very good insights there! This sort of feedback is exactly what I was looking for when I posted this on the Arc forum, because I haven't actually done much Lisp before this

On to the specifics:

For quasiquote... yeah it had occured to me that almost every time I am not 'unquoting' a symbol then this is a mistake... but only when writing a macro. Outside a macro it's less clear that this is what someone would want.

And to clarify, you mean that :

    `(one two (three))
would expand into

    (list one two (list three))
NOT

    (list one two (three))
So maybe a "define-hygienic" macro could re-define quasiquote in this fashion - but elsewhere it would work as normal.

I had also realised that the "hygiene" is currently broken by the fact that, in FirstClass Lisp, "quasiquote", "quote", "unquote", "unquote-splicing", "dot" and "slash" are all "special" in terms of what the reader reads in, so something like the following:

    (lambda (quote phrase)
        ('quote-tag quote phrase))
will not do what the author probably intended. It's easy enough to work around it - but it's unsatisfactory.

It seems to me that the correct resolution is to have the reader itself also have a lexical environment which it refers to when generating these special symbols - although you would then have the problem of how to supply this environment to the reader. Something like:

    (define quasiquote ...)
    (set-reader-environment! (env))
    `(a list)
would work... although the mutation is inelegant.

By far the most interesting statement you've made is that making the macros first class isn't actually necessary for this hygiene trick anyway! That's a very interesting statement... I need to think about this. What I most wanted was a "simple" concept of hygienic macros - that is, simple in understanding how they work: that they are just functions which happen to operate on the unevaluated source tree and return a source tree to be evaluated. Once we have that, I think the next most important thing is that there is no performance cost to using them. If what you're saying is true then it might be possible to expand all of the "non" first class macros in a pre-compilation step anyway.

I'd really like to get the Sudoku solver at least at the same level of performance as the Python one.

One area in which the first class nature of the macros was particularly elegant was in the implementation of an "amb" macro. All of the classic examples of amb require some sort of global state to keep all of the continuation instances. But this is inelegant if you wanted to have multiple usages of (amb) which don't interfere with each other: suppose for example you want to create two threads - one for solving each Sudoku puzzle.

The conventional examples always add some sort of "amb-reset!" function to say "forget about everything you tried to solve before" - but this is inelegant and wouldn't work for multiple threads.

At the same time, you want (amb) to be a macro which lazily evaluates the possibilities, so that you can write code such as:

    (define (anything-starting-from n)
            (amb n (anything-starting-from (+ n 1))))

Having amb be a first-class macro allows the following pattern, which solves both of these problems:

    (define (solve puzzle failure-continuation)
        (with* (amb (make-amb-macro failure-continuation)
                assert (make-assert amb))
        ... stuff requiring amb and assert
    )
So we have a "solve" function whose use of 'amb' is entirely an implementation detail, which means you're guaranteed that it won't interfere with anyone else's use of the amb macro.

Here's the way I defined "make-amb-macro" and "make-assert":

    ; A hygienic 'amb' macro.
    ;
    ; Using a factory function allows us to maintain
    ; the hygiene of 'amb-fail'.
    ; Use 'make-amb' to make an
    ; amb macro that you know won't interfere
    ; with anyone else's amb macro.

    ; The ability to do this - return a hygienically
    ; scoped 'amb' macro from a
    ; function, is something that is only possible
    ; in a Lisp with First Class macros and continuations
    ; (i.e. First Class Lisp!)
    (define (make-amb-macro exhausted)
        (define amb-fail exhausted)
        (define (set-fail thunk)
            (set! amb-fail thunk))
        (define (get-fail)
            amb-fail)

        ; Based on
        ; http://c2.com/cgi/wiki/?AmbSpecialForm
        (define amb
            (define expand-amb (lambda
                ()  (list force (get-fail))
                (x) x
                (x y)
                    (with* (old-fail (gensym)
                            c (gensym))
                    `(,let ,old-fail (,get-fail)
                        (,force
                            (,let-cc ,c
                                (,set-fail
                                    (,make-thunk
                                        (,set-fail ,old-fail)
                                        (,c (,make-thunk ,y))))
                                (make-thunk ,x)))))
                (x . rest)
                    `(,amb ,x (,amb ,@rest))))
         (macro expand-amb))
        amb)

    ; Given an amb macro, make an appropriate
    ; assert function. Once again, this sort of
    ; thing is only possible with first-class macros.
    (define (make-assert amb)
        (lambda
            (#f) (amb)
            (condition) #t))

And to top it off: it looks like a forgot a "," before a make-thunk in there. Yes, a "quasiquote" which by default unquotes is a good idea!
234.

Thanks for that "kernel" of information about "apply"!!

Yeah the one catch to caching the macro expansion is if the macro depends on something which subsequently changes after the expansion is cached. In practise I was not that bothered about this - I never ended up needing to write such macro.

235.
1 point by synasta 5067 days ago | link | parent | on: Newbie at programming

Just curious, how is the programming of the forum done so that registration was so simple yet without any of the annoying authentication measures everywhere else there is no spam?
236.
3 points by synasta 5068 days ago | link | parent | on: Newbie at programming

Hi,

thanks for being so helpful guys. My brother set me up with a server and am currently learning PHP. FYI, I am interested in learning programming as a hobby. Right now, i am trying to understand the fundamentals of computer programming through some pretty basic tutorials.

237.

In essence, my argument was

* How many concepts must be taught to the child before writing useful programs?

* How many of those concepts are right there, and how many are hidden?

I intuitively feel that Kalimat's example is just more simple and direct than the Logo equivalent, but "intuitively feel" and "just more simple..." are not very scientific; perhaps when Kalimat is more experimented with, we could have more empirical results.

But at least I can try to justify my feelings a little:

* The Logo example seems more nested while the Kalimat one is flatter. "Do this task, then that one" seems easier to keep inside one's head than do this task, which is made out of so and so.

* The Kalimat example completely avoids the need to teach function definition and invocation.

* The Logo code needs a discussion about variable scope and function activations; how :numberoftimes has a value in this greet different from that greet.

Yes, in Kalimat we'd have a related discussion about mutable variables, but a variable is an isolated concept that doesn't need to be explained alongside invocation and scope (at this level).

But again, you've made me look again at my assumptions and those of the Logo creators, and ask myself again and again about those assumptions; and that's definitely a good thing :)

238.

I appreciate the horizon expansion attempt :)

When I was talking about "less mysterious and complex" I wasn't thinking about how a real CPU works, but how a programmable machine works.

My idea is that a language too high-level would make the child think of a computer as something having human-like behavior, that the computer just "knows" what to do when you talk to it. On the other hand a programming language with a well-known execution model and few assumptions would mean the child can know early how to map a language's syntax to its semantics.

Let's compare two programming languages for children, Logo and Kalimat. To print "hello" ten times in Logo:

repeat 10 [print "hello]

Here the child has to either assume the computer 'just knows'/be told "you'll understand later", or otherwise has to take some conceptual leaps in order to understand what's really happening:

* The stuff between [] is code not to be executed yet, a description of a future action to be applied

* This code is given to 'repeat'

* 'repeat' would apply this code as many times as needed

Now in Kalimat:

label top

x = 0

print "hello"

x = x + 1

if x<10 : goto top

Assuming the child already knows assignment 'if', and 'goto', the code here can be analyzed, traced, and adapted, without having to know little more than what is already known.

When the student becomes more confident, they can learn about 'for' and 'while', while being told that under the hood, those high-level constructs are pretty much the same as the previous version.

As for the many other points in your comment, I'll happily be re-reading them and pondering :)

239.

I decided when writing Kalimat to enable a teacher - if they so choose - to remove all sorts of abstraction and write code that resembles how it's going to run. When dealing with a child I think learning to code is more important than learning to code well, and removing all obstacles for that is a good design choice.

This way, the student can go directly into writing interesting programs using only if/goto/expressions. Later they can learn more disciplined forms like procedures or OOP, also included.

But I don't want to impose my ideas on users; if the teacher disagrees with me, they can completely ignore goto and use other control structures!

240.

Glad you seemed to like the post!

I don't have empirical evidence, but I think that the advantage of 80s basic for learning is that there are no hidden semantics that need to be known -- what you see is exactly what you get. No parameter passing, no local variables, no call/return (except in gosub, which is presented later), no blocks...Basic is - in a sense - like assembly language with math expressions and graphics.

More modern languages for teaching are usually very high level and focus on how to make cool things with the computer, but IMO they make the computer seem mysterious and complex, since the child knows that if they write that code so and so will happen, but don't understand how it happens. I think a language more resembling the computer's execution model is better to demystify programming.

More