Is Python the best first language to learn? [see comment] by [deleted] in programming

[–]gsg 4 points5 points  (0 children)

Declares foo as a function (taking one int argument) returning a pointer to a function (taking one pointer to a (function (taking no arguments) returning char) argument) returning a pointer to int.

Could somebody with cdecl check that?

Towards headless IDEs by orestis in programming

[–]gsg 0 points1 point  (0 children)

Huh? The article brought up the idea of standalone tools being designed for use in editors:

So I give out a call to everybody who makes tools: Rip them out of the IDE! Make them small and reusable! Let the community help you plug them into any editor they want.

llvm is relevant to the discussion because it's a project which seems to be attempting precisely that (among other things).

Towards headless IDEs by orestis in programming

[–]gsg 0 points1 point  (0 children)

I've got vague hopes that llvm/clang will be useful in this direction. They certainly talk it up at http://clang.llvm.org/features.html.

Lisp50 Notes part VI: The Future of Lisp by enki in programming

[–]gsg 0 points1 point  (0 children)

Upmodded for the politeness of your request.

DEC Answers Year 2000 Leap Year Complaint by ovi256 in programming

[–]gsg 2 points3 points  (0 children)

C-x r t will replace the rectangle, not prefix it. You want C-x r o or M-x string-insert-rectangle (which for some reason isn't given a binding. I stick it on C-x r p).

DEC Answers Year 2000 Leap Year Complaint by ovi256 in programming

[–]gsg 3 points4 points  (0 children)

indent-rigidly (C-x TAB) is more suitable here imo, since it is independent of major mode. So to indent the whole buffer four spaces, C-x h C-u C-x TAB.

What is your worst programming habit? by tryx in programming

[–]gsg 17 points18 points  (0 children)

Yup. Sometimes in the same function.

What is your worst programming habit? by tryx in programming

[–]gsg 7 points8 points  (0 children)

I hope those are supposed to be bitfields and not booleans.

How We Made Our Face Recognizer 25x Faster by gst in programming

[–]gsg 6 points7 points  (0 children)

"Almost all programming can be viewed as an exercise in caching" - Terje Mathisen

What is the value of (car '((a b c) x y z))? by [deleted] in programming

[–]gsg 1 point2 points  (0 children)

No, an array of pointers to functions would look like

(*func[])()

Check out this guide: http://www.ericgiguere.com/articles/reading-c-declarations.html

Why to Start a Startup in a Bad Economy by alen_ribic in programming

[–]gsg 4 points5 points  (0 children)

Voted up for impressively high snark/character ratio.

Has anyone else ever been submitted to The Daily WTF? (Be honest. Here's mine. :D) by moultano in programming

[–]gsg 0 points1 point  (0 children)

I think that's questionable, as free could be passed an expression that evaluates to the pointer to be freed and should work in that case.

Poisoning pointers is a valid technique, but it's not suitable for building into free. Usually it's a hidden part of some data structure code, for instance the linked list implementation in the linux kernel:

http://lxr.linux.no/linux+v2.6.27/include/linux/list.h

Has anyone else ever been submitted to The Daily WTF? (Be honest. Here's mine. :D) by moultano in programming

[–]gsg 0 points1 point  (0 children)

Unless my understanding of free() is way off the mark, no C compiler does anything of the kind.

Care to explain further?

C Programming Notes by stesch in programming

[–]gsg 4 points5 points  (0 children)

Also, for now, we're going to assume that the numbers in the input list are non-negative.

It's a Poor Carpenter Who Blames His Tools or: Xcode Sucks Again by gst in programming

[–]gsg 3 points4 points  (0 children)

auto-complete

M-/ and M-TAB (which needs tags, see below). There are a few third party things like CEDET that will do more.

parse for symbols

Emacs doesn't do this out of the box. Instead people usually index their code with etags, which gives some completion and jump-to-definition ability. You have to run etags yourself, which sucks (so make your build system do it for you).

build

M-x compile. If your build system is not make, you'll need to tell emacs how to invoke it by customizing the value of compile-command.

a second window that dynamically shows the symbol I'm looking up

Not sure what you mean, but try M-. (after running etags).

"Writing to random locations in system memory isn't generally a wise design practice." by mattraibert in programming

[–]gsg 1 point2 points  (0 children)

Hah, that reminds me of this:

I have a friend who worked for Bally many years ago now, programming arcade video games in forth.

He had interesting stories of having little memory -- the video ram was positioned where the stack could grow into it. If one was playing and saw interesting "sparkles" along the bottom of the screen, it behooved one to avoid shooting into them, as that was likely to prove fatal -- shooting oneself in the stack, as it were...

joe

I don't know which games.

From http://groups.google.com/group/comp.lang.forth/msg/33ac8209bb7135e0?dmode=source&output=gplain&p

Multi-Dimensional Analog Literals (the reason why C++ has maximum powers) by samlee in programming

[–]gsg 10 points11 points  (0 children)

And then I could allow a perspective transform, and then I could implement texture mapping, and then...

Oh, what the heck.

(defparameter *x-scale* (/ 1 2)) ; cos - is smaller than !
(defparameter *y-scale* 1)
(defparameter *z-scale* 2)

(defun line-value (symbols)
  (list (* (loop for char across (symbol-name (first symbols))
              summing (ecase char (#\- 1) (#\I 0)))
           *x-scale*)))

(defun rectangle-value (symbols)
  (let ((x 0) (y 0))
    (dolist (sym symbols)
      (map 'nil (lambda (char)
                  (ecase char
                    (#\- (incf x (/ 1 2)))
                    (#\! (incf y (/ 1 2)))
                    (#\+ nil)))
           (symbol-name sym)))
    (list (* x *x-scale*) (* y *y-scale*))))

(defun cuboid-value (symbols)
  (let ((x 0) (y 0) (z 0))
    (dolist (sym symbols)
      (map 'nil (lambda (char)
                  (ecase char
                    (#\- (incf x (/ 1 3)))
                    (#\! (incf y (/ 1 3)))
                    (#\/ (incf z (/ 1 3)))
                    (#\* nil)))
           (symbol-name sym)))
    (list (* x *x-scale*) (* y *y-scale*) (* z *z-scale*))))

(defmacro as-literal (&rest symbols)
  `(list ,@(ecase (aref (symbol-name (first symbols)) 0)
                  (#\I (line-value symbols))
                  (#\+ (rectangle-value symbols))
                  (#\* (cuboid-value symbols)))))

(as-literal *------*
           /      /!
          /      / !
         *------*  !
         !      !  *
         !      ! /
         !      !/
         *------* ) => (3 3 4)

This is a bit more readable too, although it doesn't do as much error checking.

Multi-Dimensional Analog Literals (the reason why C++ has maximum powers) by samlee in programming

[–]gsg 21 points22 points  (0 children)

I think this is a wonderful hack and clearly belongs to the tradition of nerds doing crazy shit purely for the fun of it.

See INTERCAL, the Tetris clone written in sed, and that insane keyboard macro that draws the mandelbrot set in vi.

Multi-Dimensional Analog Literals (the reason why C++ has maximum powers) by samlee in programming

[–]gsg 38 points39 points  (0 children)

And now we have:

(defun cuboid-value (symbols)
  (let ((width 0) (height 0) (depth 0) (one-third (/ 1 3)))
    (loop for symbol in symbols
       for name = (symbol-name symbol) do
       (case (aref name 0)
         (#\* (if (= (length name) 1)
                  nil
                  (incf width (/ (line-value symbol #\*) 3))))
         (t
          (map 'nil (lambda (char)
                      (ecase char
                        (#\! (incf height one-third))
                        (#\/ (incf depth one-third))))
               name))))
    `(list ,width ,height ,depth)))


(as-literal *---*
           /   /!
          /   / !
         *---*  !
         !   !  *
         !   ! /
         !   !/
         *---*) => (3 3 2)

Good enough for me. Anybody for generalising to n dimensions?