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

Pages: 1-

Definitions

Name: Anonymous 2010-11-16 4:30

So DrRackert let's me make definitions in the top window, but then it calls these constants, like if I do a simple

(define a 10)

If I try to re-define or set! a 15 then the interpret gets angry and says that a is a constant

How do I define something that can change values?

Name: Anonymous 2010-11-16 4:37

Less of this.

Name: Anonymous 2010-11-16 4:37

DrRackert
;-)

Also,
let's
Faggot.

Name: Anonymous 2010-11-16 4:47


Welcome to DrScheme, version 4.2.1 [3m].
Language: R5RS; memory limit: 128 megabytes.
(define a 13)
(set! a 2)
a
2


Oldfagish DrScheme with R5RS >>>>>> DrRacket 5.0.whatever with Racket language.

Name: Anonymous 2010-11-16 10:09


Welcome to DrRacket, version 5.0.1 [3m].
Language: scheme; memory limit: 128 MB.
(define a 10)
(set! a 12)
a
12


OP is full of shit

Name: Anonymous 2010-11-16 11:21

Well here is the exact code:

#lang racket/gui
(require (lib "gl.ss" "sgl")
         (lib "gl-vectors.ss" "sgl")
)
(define (resize w h)
  (glViewport 0 0 w h)
  #t
)
(define (draw-opengl)
  (glClearColor 0.0 0.0 0.0 0.0)
  (glClear GL_COLOR_BUFFER_BIT)
  (glColor3d 1.0 1.0 1.0)
  (glMatrixMode GL_PROJECTION)
  (glLoadIdentity)
  (glOrtho 0.0 1.0 0.0 1.0 -1.0 1.0)
  (glMatrixMode GL_MODELVIEW)
  (glLoadIdentity)
  (glBegin GL_QUADS)
  (glVertex3d 0.25 0.25 0.0)
  (glVertex3d 0.75 0.25 0.0)
  (glVertex3d 0.75 0.75 0.0)
  (glVertex3d 0.25 0.75 0.0)
  (glEnd)
)
(define my-canvas%
  (class* canvas% ()
    (inherit with-gl-context swap-gl-buffers)
   (define/override (on-paint)
      (with-gl-context
        (lambda ()
          (draw-opengl)
          (swap-gl-buffers)
        )
      )
    )
    (define/override (on-size width height)
      (with-gl-context
        (lambda ()
          (resize width height)
        )
      )
    )
    (super-instantiate () (style '(gl)))
  )
)
(define win (new frame% (label "OpenGl Test") (min-width 200) (min-height
200)))
(define gl  (new my-canvas% (parent win)))
(send win show #t)


My intention is to change 200 for the height and width to a variable, then use the interpreter to change the variable. If I define height2 and width2, it calls them constants.

Name: Anonymous 2010-11-16 11:36

Well where is the exact code tags?:

Name: Anonymous 2010-11-16 11:52

|

Fuck you too

Name: Anonymous 2010-11-16 11:52

>>7
lol what?

If you meant changes I made, I just put (define height2 300) (define width2 300) after the first opengl definition, replace the 200s with their appropriate replacement, run the program, and try and redefine one of em.

The exact error is:

define-values: cannot re-define a constant: width2

Name: Anonymous 2010-11-16 12:40

You have a rather ugly way of closing parens. This isn't C, you can close all of them on one line.

Name: Anonymous 2010-11-16 12:53

>>6
What the fuck are you doing with those parens? Format it right, faggot.

Name: Anonymous 2010-11-16 12:56

Finally someone who writes readable Scheme code.

Name: Anonymous 2010-11-16 13:18

>>9 That's what you meant!
Read "http://lists.racket-lang.org/users/archive/2009-January/029884.html"
TL-DR. Use

(define my-height "MY ANUS")
(set! my-height 200)

so it will not be considered as constant by repl.

also

        )
      )
    )

WTF am I reading?

Name: Anonymous 2010-11-16 13:20

>>11
BTW. Is there a shortcut to format them nicely?

Name: Anonymous 2010-11-16 13:22

>>14
Yeah, try not pressing the return key before you type them. I use paredit so I don't have to type closing parens at all.

Name: Anonymous 2010-11-17 0:06

wow someone who finally learns how to indent his fucking lisp and you all faggots bitch at him? fuck you prog

Name: Anonymous 2010-11-17 1:05

>>13
Great! It no longer gives me an error.

Unfortunately, it doesn't change the screen width/height BUT it does change that value, and that is absolutely useful. Probably something to do with the screen-size maker thing running only once, then it continuously draws the stuff inside it, or even a single frame, I can't decipher this code.

The code was copypasta from a google groups on OpenGL, I did not do indenting or anything

Name: Anonymous 2010-11-17 1:08

>>13
>>17
I think I may have noticed why it does that behavior - they mention it can be a compile time optimization, that makes me believe that the first reference initials the data to that value, while forcing constant, THEN the following set! changes it to a variable, otherwise, it'd be kind of hard to have both behaviors possible with special flags.

Name: Anonymous 2010-11-17 1:43

Grr, if I send the initialization command after set!ing the variables, it doesn't change the window size.

Any ideas?

Name: Anonymous 2010-11-17 1:45

>>19
call resize.

Name: Anonymous 2010-11-17 4:30

>>20
Doesn't work, derp a derp

Name: Anonymous 2010-11-17 11:25

>>21
Call it correctly

Name: Anonymous 2010-12-21 6:53

Name: Anonymous 2011-02-03 5:06

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