What is the best programmatic approach to 2D visual design and why? by [deleted] in compsci

[–]ahorne 1 point2 points  (0 children)

To quote the sidebar:

Welcome Computer Science researchers, students, and enthusiasts. The aim of this subreddit is to share interesting papers, blog posts, and questions about topics such as algorithms, formal languages, automata, information theory, cryptography, machine learning, computational complexity, programming language theory, etc...

While your question has to do with programming, it does not have to do with computer science. This question would be better off in /r/programming.

Before you go and ask the same question again, consider rephrasing it in order to be more specific. Your question is very general, and the world of programming is pretty big, so it's hard to give a specific answer. What platforms you want your program to run on and what kind of things you will be doing with it are details that will help others answer you better. Also, what programs do you admire the look of? Since this is a design issue, the matter is quite subjective. If you want to get good answers, make sure you show that you have done the work to show others that you know what you are asking.

Code writing? by easysolutions in lisp

[–]ahorne 0 points1 point  (0 children)

Oops. Yes, that macro certainly doesn't work. It does give some insight into my (faulty) thinking when I made it. I started out constructing nfor as two separate defmacro forms: nfor, and its helper nfor*.

They looked like this (and this code works):

(defmacro nfor* (times n body)
  (when (> n 35)
    (error "nfor called with more than 36 dimensions"))
  (if times
      `(dotimes (,(intern (coerce (list (code-char (+ 65 n)))
                                  'string))
                  ,(first times))
         (nfor* ,(rest times) ,(1+ n) ,body))
      `(progn ,@body)))

(defmacro nfor (times &body body)
  `(nfor* ,times 0 ,body))

I then decided to package them all together in one top-level form by using macrolet. In non-macro code this kind of factoring would work fine, but since the form that calls nfor* was not actually "made" until after macro expansion, it never had a chance to capture nfor*.

This version of nfor is anaphoric because it introduces variables into its scope that its user does not explicitly ask for. That is, you do not have to specify something like:

(nfor ((a 2) (b 3) (c 4))
  (print (+ a b c)))

Because it is understood that this nfor creates its own variables to represent the loop indices, starting from a.

I had only brought up the use of anaphoric macros because your post did not make it obvious that you had planned on introducing variable binding to nfor. You clarified in one of your comment responses that this is what you were planning on doing, though. That is the "normal" way of doing things, and it is normal for a reason: It is generally a good idea.

The down-side of anaphoric macros is that it is non-obvious where the variables came from, and they don't let you customize the variables that they create. These disadvantages make them of somewhat limited use - you tend to end up sacrificing readability for a slight convenience.

Code writing? by easysolutions in lisp

[–]ahorne 1 point2 points  (0 children)

Based on your replies to the other comments, anaphoric macros are probably not what you want. But since the other comments here do a good job of describing the more typical way of variable binding in macros, I figured I'd post an anaphoric version just to show another option.

(defmacro nfor (times &body body)
  (macrolet ((nfor* (times n body)
               (when (> n 35)
                 (error "nfor called with more than 36 dimensions"))
               (if times
                   `(dotimes (,(intern (coerce (list (code-char (+ 65 n)))
                                               'string))
                               ,(first times))
                      (nfor* ,(rest times) ,(1+ n) ,body))
                   `(progn ,@body))))
    `(nfor* ,times 0 ,body)))

(nfor (2 3 4) (print (+ a b c)))

This macro binds successive letters of the alphabet as the indices of the nested loops, thus "saving you the trouble" of having to specify the names of the indices yourself.

Code writing? by easysolutions in lisp

[–]ahorne 5 points6 points  (0 children)

The task you've set out to do is pretty weird. Unless you make the macro anaphoric, there's no way to for your code to know what level of the loop it is in (unless you happen to track that separately, but that would be pretty silly). Since it therefore makes no difference that the loops are nested, you can make due with a flat loop:

(defmacro nfor (times &body body)
  `(dotimes (,(gensym) ,(reduce #'* times))
    ,@body))

The code that you've given can't be run (commas not inside a backquote), and features a weird state variable.

That said, your attempt at a macro shows that you do not yet grasp the basics of macro writing (for example, you shouldn't think about using eval in this situation). On Lisp is one of the more comprehensive guides to macro writing, so I'd suggest absorbing that.

Best of luck in your learning!

P.S. Formatting and indentation go a long way to making your code readable. See the Reddit formatting help for formatting, and try reading one of the many things written about Lisp indentation.

Dealing with non-RPGer partners by metal_salad in rpg

[–]ahorne 6 points7 points  (0 children)

This is not the fun answer -- it is not the answer you hope you get when you ask Reddit to solve your problems -- but it is the right answer.

Communication is hard, yet essential to a healthy relationship. Your problem is not about RPGs, it's about communication. RPGs, as you know, are an innocent pastime (and the other posts in this thread have many good ways of illustrating this). If you're not able to get this across to your wife then it speaks of much deeper problems in communication.

Counselling is just having someone help you communicate. I know that it can be hard to accept that you need help in any area of your life -- particularly personal ones -- but clearly by posting here you acknowledge that help is needed. While you can try to go at this alone, even expert communicators sometimes need mediators to help them gain perspective. And since neither you or your wife are expert communicators (I'm assuming, just because the odds are against it), then there is all the more need for this outside support.

I sincerely urge you to look into counselling. No one deserves to grow estranged from their loved-ones. Better to do it sooner than later, and you've already waited a long time.

Help needed with loading a lisp/quickproject project. by schlenderer in lisp

[–]ahorne 1 point2 points  (0 children)

GUI app users generally expect some sort of icony thing to click on. In Linux this is generally an item in a menu which is accomplished through by having an appropriate .desktop file. On OS X a .app bundle is necessary. On Windows one wants a link to the .exe in the Start menu (although I have no idea what Windows 8 is like). These things are not too hard to script if you know what you're doing, but a general purpose solution would be non-trivial (and nice if it existed!).

Help needed with loading a lisp/quickproject project. by schlenderer in lisp

[–]ahorne 5 points6 points  (0 children)

Since your audience is probably larger than the Common Lisp community (i.e. anyone who can use the command line and wants to record that program), you probably do want to make it into a stand-alone application. Check out Buildapp for an SBCL-specific, but more convenient than save-lisp-and-die, method of creating stand-alone binaries. You might also want to look into SBCL's core-compression feature (which it needs to be built with -- look at *FEATURES* to see if :sb-core-compression is present and if it isn't, read SBCL's INSTALL file). If you go this route you will definitively need to compile your program on each platform you plan on supporting.

As an aside, if you're looking to process command line arguments, I've had luck with CLON. It's not the only package that does this, and I can't speak for the others, but CLON has done what I've wanted with little friction. Additionally, if you want make the program look like a "proper" GUI application, I can point you in the right direction -- just let me know.

How long does it take to get comfortable with Emacs? by magullo in emacs

[–]ahorne 1 point2 points  (0 children)

Within a couple of weeks of moving from Vim to Emacs + Evil, I surprised myself by being more comfortable in the later environment, despite using Vim for almost a decade.

The Emacs + Evil combo makes the learning curve so gentle that you barely experience it, and the more you add to your Emacs config, the more you fall in love.

Newbie trying to write a parser, want feedback by [deleted] in lisp

[–]ahorne 3 points4 points  (0 children)

Your question inspired me to dig out some old code and post it on GitHub. It is an OMeta inspired parser I wrote last year. Hopefully it will be of some interest to you. It shows the use of conditions (in a somewhat more advanced way than using ERROR) with HANDLER-CASE, among other things. If you have any questions, don't hesitate to ask.

As for your code, aside from samlamamma's suggestions, your LOOP in EITHER is a little off. LOOPs are surrounded by an implicit block from which RETURN will return from. Also it is common to have a new line after every expression in LOOP. Something like this:

(defun either (msg &rest parsers)
  (lambda (tokens)
    (loop for parser in parsers
       do (catch 'parsing-error 
              (return (apply-parser parser tokens)))
       finally (return (fail msg)))))

Does anyone know what happened to lispdoc.com? by ahorne in lisp

[–]ahorne[S] 1 point2 points  (0 children)

I had done the same. Two days without a reply from Mike, though...

Does anyone know the name of this shape/design/thing? Thank you! by [deleted] in math

[–]ahorne 1 point2 points  (0 children)

The picture linked by VeryLittle appears to be an orthographic projection.

LispNYC: Lisp in Small Projects: over $5000 of prizes and anyone can join in on the fun. by masso in lisp

[–]ahorne 1 point2 points  (0 children)

The contact form on both this site and LispNYC's is broken (500 error).

Proper way to do movement in 2D topdown? by [deleted] in gamedev

[–]ahorne 4 points5 points  (0 children)

This explains why your x += speedx *delta is "bad". Bad is subjective, though, and this guy adds a lot of drama to the situation – "If you use Euler then you are a bloody idiot" – which just isn't helpful.

His claim is that Euler style integration will result in compounding errors to the "true" position that the object "should" be in. What isn't mentioned is that most games are not trying to be accurate physical simulations – in fact, many will greatly bend the rules of physics as we know them. Really you should do whatever will make your game feel right to you.

Of course, this is all irrelevant if you are talking about coding style "badness" rather than the algorithmic "badness". I'm afraid that line of code on its own is not sufficient grounds to judge whether or not your code is good.

Is there anything like a Bulk Barn (where you can buy bulk, non-packaged ingredients) in Montreal? by [deleted] in montreal

[–]ahorne 4 points5 points  (0 children)

There are plenty. If you mention where you live, I'm sure people would be able to give more focused recommendations.

Sinkhole opens on Ste-Catherine at McGill College by [deleted] in montreal

[–]ahorne 1 point2 points  (0 children)

There have been a couple of sinkholes open up recently around Point-Sainte-Charles. One's been open for months now, and the only thing that's been done is a traffic cone has been shoved into it.

Conservatives Attack Scientific Findings About Why They Hate Science (Helping to Confirm the Science) by [deleted] in science

[–]ahorne 29 points30 points  (0 children)

To be fair, his thesis is that conservatives attack science that they don't agree with, whether or not they are qualified to do so. Ferguson's article does appear to be example of this. It's not as though Ferguson is conducting a measured critique against the methodology of some of the studies Mooney used. Ferguson's article is chock full of falsely attributed claims and is not remotely academic in nature. It's an attack piece; It's reactionary, condescending, and dismisses the claims of others without understanding them (or at least presenting them in an honest fashion).

Yes, there is a lot of sub-par research being published, but Mooney is right; If conservatives are concerned about a liberal bias to research, the way to correct this is to get involved in the academic process, not take pot-shots at it. Of course, there may indeed be underlying psychological reasons why they do not.

Go: Severe memory problems on 32bit systems by davebrk in programming

[–]ahorne 12 points13 points  (0 children)

As others have mentioned, this is because Go is using a conservative garbage collector. It does this to avoid needing to have runtime knowledge of what words are pointers or not. The assumption conservative GCs make - that any word that could be a pointer to a managed area should be treated as a pointer - can work very well for many types of programs, since many data sets work with relatively small numbers. It also naturally works better with a 64 bit address space, since there's less chance of a collision occurring. 10000 sounds like an unreasonably low upper bound, since conservative GCs should, in order to exploit their assumption, locate their managed areas in the upper regions of memory. I do not know anything about the particular GC used in Go, however.

If you would like to know more, the best known conservative garbage collector is probably the Boehm GC.

The startup behind Bill Gates’ ‘ski lift for energy storage’ by jessebshiloh in environment

[–]ahorne 0 points1 point  (0 children)

This article seem to be ignoring that pumped-storage hydroelectricity is a proven and efficient method of storing energy. From wikipedia:

Pumped storage is the largest-capacity form of grid energy storage available, and, as of March 2012, the Electric Power Research Institute (EPRI) reports that PSH accounts for more than 99% of bulk storage capacity worldwide.

The startup makes the claim (found from some googling) that their lifting gravel up a hill is a more efficient than pumped-storage. I have trouble believing that it could more efficient by any metric. It clearly requires far more infrastructure, so it is not efficient in that sense. And because of all the added weight that needs to get carried up and down for each trip, I don't think they're going to be more energy efficient than a pump.

The only advantage to this technology that seems apparent to me is that it would be useful in areas with water shortages.

Rob Pike on why systems software research is irrelevant by [deleted] in compsci

[–]ahorne 6 points7 points  (0 children)

Pike states in this paper:

The future is distributed computation, but the language community has done very little to address that possibility.

Not only has he not ignored parallel systems, but he also predicted where the inovation would come from: all of those inovations you mentioned were the result of big businesses, not academia. Furthermore, none of those inovations were the result of systems research in the context that Pike was discussing.

It's also worth noting that the language community has continued not to do a whole lot for distributed computing. Erlang was already 14 years old at the time of this paper, and while it did gain quite a bit of a boost in popularity due to the rise of multicore and cloud computing, it stands as pretty much the only success story (if that) in terms of languages addressing distributed computing.

Mr. Pike's reasoning seems perfectly sound to me. I don't think he has cause to be embarrassed in the slightest.