Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

scheme question

Name: Anonymous 2013-03-31 11:27

Hello /prog/, I'm not really much of a programmer but I've been dicking around with Lisp/Scheme lately for fun (DrRacket specifically).  One of the programs in my book goes like this:

;; move-circle : number circle  ->  circle
;; to draw and clear a circle, translate it by delta pixels
(define-struct circle (center radius color))

(define (move-circle delta a-circle)
  (cond
    [(draw-and-clear-circle a-circle) (translate-circle a-circle delta)]
    [else a-circle]))

draw-and-clear-circle draws and clears a circle, obviously, and translate-circle simply modifies the given "circle" structure such that its position is shifted by "delta" pixels.  So if I wanted to make a circle move across the screen I could run something like

(draw-a-circle (move-circle 10 (move-circle 10 (move-circle 10 (make-circle (make-posn 30 30) 45 'red)))))

Anyway my question is simply this: why is there an "else" at all in that conditional?  The function "draw-and-clear-circle" always returns a value of "true", or, if there's something wrong with the definition of the circle structure, an error.  So afaik the "else" would never come into play.

Name: expert brogrammer 2013-03-31 11:44

scheme
if it aint lisp it aint shit

Name: Anonymous 2013-03-31 11:44

fghhhhhhhhhhhhhhhhhhhhhhhhhhhhhjjjjjjjjj5e

Name: Anonymous 2013-03-31 13:16

>>1
It seems like it. It's a rather odd choice; the library procedures all assure that they'll evaluate to true, but since they return boolean value, the authors wrote the procedures as though they actually signaled something for your program's flow, even if they don't.

I'm not sure I like it; as of the writing of that program, there's no case in which the procedures will evaluate to false, so there's no assurance that merely returning the unmodified circle is an acceptable result for the procedure, and that the program is in a ``good'' state.

If you spoil yourself the answer, you can see what they had in mind: http://htdp.org/2003-09-26/Solutions/circ-draw-and-clear.html

Name: Anonymous 2013-03-31 13:21

Hello /prog/, I'm not really much of a programmer but I've been dicking around with Lisp/Scheme lately for fun (DrRacket specifically)
Just how long is your fucking Scheme course, Python-kun?

Name: Anonymous 2013-03-31 13:25

>>1
(define-struct circle (center radius color))
Better use a simple lambda based OOP, like described in Lambda the Ultimate papers. I'm sure, Racket allows type-tagged closures.

Name: Anonymous 2013-03-31 14:19

>>6
See, people like you are the reason people use CL for real work.

Name: Anonymous 2013-03-31 14:28

>>7
It's not our fault scheme has no native object system. But it's ok. You can do more with case over symbols anyway.

Name: Anonymous 2013-03-31 15:12

>>8
See, people like you are the reason people use CL for real work.

Name: Anonymous 2013-03-31 15:23

>>9
message passing > clos oo > java oo > seeples oo

Name: Anonymous 2013-03-31 15:35

>>10
CLOS OO can easily do message passing, Nikita Sadkike.

Name: Anonymous 2013-03-31 15:56

>>5

What are you even on about?  Who's Python-kun?

Name: Anonymous 2013-03-31 18:53

>>11
Not really. Try this in clos.


(define (integer-box value)
  (lambda (mesg . args)
    (case mesg
      ((value) value)
      ((+) (integer-box (apply + (cons value (map (lambda (o) (o 'value)) args)))))
      ((-) (integer-box (apply - (cons value (map (lambda (o) (o 'value)) args)))))
      ((*) (integer-box (apply * (cons value (map (lambda (o) (o 'value)) args)))))
      ((/) (integer-box (apply / (cons value (map (lambda (o) (o 'value)) args)))))
      (else (error mesg)))))

(define (list-box lis)
  (lambda (mesg . args)
    (case mesg
      ((value) lis)
      ((concat) (list-box (append (cons lis (map (lambda (o) (o 'value)) args)))))
      (else (list-box (map (lambda (o) (apply o (cons mesg args))) lis))))))


(define e (list-box (map integer-box '(1 2 3 4 5 6 7))))

(define f (e '+ (integer-box 10)))

(display (map (lambda (o) (o 'value)) (e 'value))) (newline)
(display (map (lambda (o) (o 'value)) (f 'value))) (newline)

Name: Anonymous 2013-03-31 19:18

>>13
I don't understand the point of this, you're just implementing dumb classes à la Java.

Name: Anonymous 2013-03-31 19:26

>>14

The interesting part is the else case of the list class.
The list class sends all unhandled messages to its members. Did you run it?

Name: Anonymous 2013-03-31 19:35

>>15
I am unconvinced that that bit of artifice (namely, automatically mapping over containers) justifies this paradigm. Moreover, I am certain that the same can be accomplished in a CLOS-style object system with multimethods.

Name: Anonymous 2013-03-31 19:41

>>16
I am unconvinced that that bit of artifice (namely, automatically mapping over containers) justifies this paradigm.
It's just an example.

Moreover, I am certain that the same can be accomplished in a CLOS-style object system with multimethods.
Then try it. The strength in this case is that the message name is first class. The message is a value in a variable that can be passed on to any object(s).

Name: Anonymous 2013-03-31 19:45

But if you wanted to do this with clos, you'd have to catch a bad multimethod call on the list class, and then pass the invoked multimethod and arguments onto the list contents. It might be possible, but I'm not sure how you would do it, since the rule would apply for all methods, but only on the list class. Smalltalk supports this.

Name: Anonymous 2013-03-31 19:52

>>18,19
This is interesting and I would like to pursue this discussion further, however I am currently under the effects of sleep deprivation. I will answer you after a short nap.

Name: Anonymous 2013-03-31 20:05

Sleep well. May your dreams be infested with the wonders of meta object programming.

Name: Anonymous 2013-03-31 22:36

>>20

Yeah they will be, I hate that shit, when I was in college and I went to bed with a sentence untranslated I would dream about trying to translate that sentence all night, and when there's something wrong with a program the same thing happens.  It's like the tetris effect but all night and a lot worse.

Name: Anonymous 2013-03-31 22:57

>>11
CLOS is definitely not easy and over-engineered. CLOS also impedes encapsulation, because generics are global. I.e. CLOS fails to provide the main benefit of OOP - replacing packages. You can't use a CLOS object as a package.

Name: Anonymous 2013-03-31 23:29

>>22
But you can put generic functions in packages. Treat the package like an interface, containing a set of generic functions. Then provide implementations for the methods using classes from other packages.

Name: Anonymous 2013-04-01 0:15

>>23
That is retarded and would end producing more verbosity than Java.

Also, I'm still in search of work, so Russian Anon please send any vacancies to http://vk.com/antisemitic or http://2ch.hk/pr/res/258636.html

Although I refuse using PHP, Haskell and Python, because they are Jewish.

Name: Anonymous 2013-04-01 0:22

>>24
...ok

...then how about putting all generic functions in their own package, and using that package in all the package you define. Wait. I'm not sure if I understand your original complaint.

Name: Anonymous 2013-04-01 0:26

>>25
Still too much engineering complexity, compare to closures, which allow producing objects in place.

Name: Anonymous 2013-04-01 0:30

>>24
...also you might have better luck looking for a job is you don't tie your antisemitism to your resume. Aside from being grotesque, it's unprofessional to throw in your political agenda. Just look at Adria Richards.

Name: Anonymous 2013-04-01 0:38

>>27
Aside from being grotesque
That is because I have little social understanding. I spent my 30 years completely inside 4 walls.

it's unprofessional
But I'm just a hobbyist guy (no school education), wanting to have a taste of real-world development. That is because I was numerously accused of having no background to back up my claims, but working with Java/C# for some time would give me full rights and experience to bash them.

Name: Anonymous 2013-04-01 1:20

>>28

Assuming you are Nikita, I'd say you are more than skilled enough to work as a developer. You might not be able to use lisp on the job, but you can recognize it's presence in xml, json, and code generation scripts. While some of its manifestations are more verbose and less reliable, it's all still there in spirit: the processing and fully customizable evaluation of structured information. Experience in lisp is handy for using these techniques effectively. And lisp's variety of features overlap in other languages, so it's not hard to move onto others.

If you want experience on your resume, you can look into what types of jobs you would like, and make some demonstration projects using the same languages and platforms. If they want experience with TEAM WORK, you can add some patches to an open source project or something.

The bigotry wont help. If I was a manager, I'd worry about you harassing coworkers and customers that are of jewish ancestry. I do hope you let it go one day, although the spam has been entertaining.

Sincerely,
a jew

Name: Anonymous 2013-04-01 1:23

>>27
Everything is ``political'' to some degree. The tone of conversation at work, the atmosphere, whether dick jokes are acceptable, whether the managers and HR are sick fucks, EVERYTHING.

Name: Anonymous 2013-04-01 1:28

>>30
Such is the shortcoming of belonging to an organization of human beings.

Name: Anonymous 2013-04-01 1:41

>>30,31
Consider this: Not everyone takes things politically, and scientifically-oriented spirits tend to have a fairly high tolerance for "social noise", be it overly formal or overly familiar (and even obscene) language. They know that human communication and social protocol are error-prone and can differ much between peers, so they follow Postel's Prescription: "Be liberal in what you accept, and conservative in what you send".
Such is the uprising of the Scientist.

Name: Anonymous 2013-04-01 2:21

>>29
I'd worry about you harassing coworkers
Jews usually avoid proletarian programming jobs, so my coworkers would likely be Hindus. Although I'm unsure if one can convert to Hinduism.

Name: Anonymous 2013-04-01 2:31

Consider this: A pack of wild Feminists.
Easily offended, socially-networked Feminists nearing your male occupation. Trampling your dick jokes. Raping your use of pronouns.
And you can't do shit since they're offended. The Feminist leader grabs your penis and says, "dick jokes create a sexually charged environment."
The progressive Feminists finally dominate your office. They hold boring dick joke free meetings and you are forced to be their slave.
Such is the downfall of Man.

Name: Anonymous 2013-04-01 2:41

>>34
Trampling your dick jokes.
I am confused, are they trampling my jokes about dicks or are they making jokes about trampling my dick?

Name: Anonymous 2013-04-01 2:42

>>35
both

Name: Anonymous 2013-04-01 2:46

>>35
learn to context free parsing

Name: Anonymous 2013-04-01 3:01

>>34
nearing your male occupation.
Actually, four out of the four female scientists/programmers (approximate ages 20,20,25,35, two white, one asian, one black) I know enjoy sexual/scatological/"offensive" jokes at the workplace and are very displeased with "easily-offended, socially-networked Feminists", much like their male counterparts. They regard them with much disdain, and qualify them as loud, manipulative, useless wastes of air (and I'm holding back, I've actually heard so much worse from the females than from the males).

This isn't about male vs female, this is about sciences vs humanities.

Name: Anonymous 2013-04-01 16:28

>>38
Deeply ingrained macho culture.

Name: Anonymous 2013-04-01 19:54

>>38
back to reddit.com/r/mensrights/ ``please''

Name: Anonymous 2013-04-01 20:15

>>40
You're the one who needs to go back to lebbit, ``heterosexual''

Name: Anonymous 2013-04-01 20:18

>>41
lebbit
Back to /b/, please

Name: Anonymous 2013-04-01 20:38

>>42
Never heard ``lebbit'' before. But you seem to be familiar with /b/'s linguo.

Name: Anonymous 2013-04-01 20:38

>>39-40
Back to /humanities/, waste of air.

Name: Anonymous 2013-04-01 20:43

>>43
Heard it a couple of times on /q/, figured that it le Reddit must be wordfiltered to that on some imageboards.

No need to thank me.

Name: Anonymous 2013-04-01 20:49

>>39
Deeply ingrained pansy culture.

Name: Anonymous 2013-04-01 21:10

>>45
I'm not familiar with /q/ either. I really have no interest in imageboards.

Don't change these.
Name: Email:
Entire Thread Thread List