Re: [racket-users] Do I misunderstand set! ?

2020-04-23 Thread Hendrik Boom
On Thu, Apr 23, 2020 at 11:40:44PM -0500, Alexis King wrote:
> > On Apr 23, 2020, at 21:15, Hendrik Boom  wrote:
> > 
> > (fprintf anomaly "resEEEulttyope was ~s~n" resulttype)
> > (fprintf anomaly "set resulttyoe to ~s~n" ty)
> > `(set! resulttype ty)
> > (fprintf anomaly "resEEulttyope now ~s~n" resulttype)
> 
> (Re-sending this because I forgot to CC the list the first time.)
> 
> Assuming it is not some strange artifact of your email client’s formatting, 
> you have a backtick at the beginning of the line your set! expression appears 
> on, so it is quasiquoted and will not do anything.

Yes!  You nailed it!  I didn't even *see* the backtick until you pointed 
it out!  Good thing I reallt copy-pasted it instead of typeing it in. 

> Both DrRacket and racket-mode communicate this information to you in 
> various ways: DrRacket won’t draw binding arrows for set! or 
> resulttype, and I believe racket-mode has similar functionality 
> (albeit displayed in a different way).

Which explains why I wasn't getting binding arrows.  Now I know what to 
look for when that happens.

-- hendrik

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200424050847.takja5obmnhvk3pl%40topoi.pooq.com.


Re: [racket-users] Do I misunderstand set! ?

2020-04-23 Thread Alexis King
> On Apr 23, 2020, at 21:15, Hendrik Boom  wrote:
> 
> (fprintf anomaly "resEEEulttyope was ~s~n" resulttype)
> (fprintf anomaly "set resulttyoe to ~s~n" ty)
> `(set! resulttype ty)
> (fprintf anomaly "resEEulttyope now ~s~n" resulttype)

(Re-sending this because I forgot to CC the list the first time.)

Assuming it is not some strange artifact of your email client’s formatting, you 
have a backtick at the beginning of the line your set! expression appears on, 
so it is quasiquoted and will not do anything. Both DrRacket and racket-mode 
communicate this information to you in various ways: DrRacket won’t draw 
binding arrows for set! or resulttype, and I believe racket-mode has similar 
functionality (albeit displayed in a different way).

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/6C5015F4-B5F8-46CB-85EF-F04BE3B0D7AA%40gmail.com.


Re: [racket-users] Do I misunderstand set! ?

2020-04-23 Thread Hendrik Boom
On Thu, Apr 23, 2020 at 05:07:31PM -0400, Philip McGrath wrote:
> I think you are running into the (very confusing!) issue Ben describes
> here: https://groups.google.com/d/msg/racket-users/UD20HadJ9Ec/mDd4x8Y1BwAJ

If so, I'm confused.  That issue seems to deal with modules.
I'm not aware of amy modules hanging around.
The creation of resulttype, the use of resulttype, and the set!ing of
resuttype all happen within one single function.

I'll paste it in below.

-- hendrik
> 
> -Philip
> 
> 
> On Thu, Apr 23, 2020 at 5:00 PM Hendrik Boom  wrote:
> 
> > extract from code:
> >
> >   (fprintf anomaly "resEEEulttyope was ~s~n" resulttype)
> >   (fprintf anomaly "set resulttyoe to ~s~n" ty)
> >  `(set! resulttype ty)
> >   (fprintf anomaly "resEEulttyope now ~s~n" resulttype)
> >
> > Previous creation of resulttype:
> >
> >   (define resulttype : (Option TType) #f) ; TODO: check there's only one
> >
> > Output that appeared on the anomaly file:
> >
> > resEEEulttyope was #f
> > set resulttyoe to _void
> > resEEulttyope now #f
> >
> > I stuck the E's in just to make sure these were the statements really
> > generating that output.
> >
> > If I am correct, the set! should have changed the value of resulttype.
> > I'm doing thie in typed-racket.

And here's the function:

(define (process-command [command : (Listof XML)])
  (fprintf output "~n") ; TODO this line is temporary code
  (define name : (Option Symbol) #f) ; TODO: check there's only one
  (define resulttype : (Option TType) #f) ; TODO: check there's only one
  (define group : (Option XML) #f)
  (define proto : (Option prototype) #f); TODO: check there's only one
  (define params : (Listof parameter)'()) ; list of parameters in reverse order
  (define glxtype : (Option String) #f)
  (define opcode : (Option String) #f)
  (for ([item command])
(match item
  #;[(list 'proto ty (list 'name n))
  `   (set! resulttype
` (if (and (string? ty) (equal? "void" (strip-white ty))) '_void 
ty))
` (fprintf anomaly "resulttype set to ~s~n" resulttype)`
` (set! name (string->symbol (strip-white n)))
   ]
  [(cons 'proto rest)
   (set! proto (process-proto (cast rest (Listof XML
   (match proto
 [(prototype ty n g) ; formerly list n ': t)
  (fprintf anomaly " prottype's type is ~s~n" ty)
  (when name (fprintf anomaly "Too many names ~s ~s~n" name n))
  (set! name n)

  (when resulttype (fprintf anomaly "Too many result types ~s ~s`n" 
resulttype ty))
  (fprintf anomaly "resEEEulttyope was ~s~n" resulttype)
  (fprintf anomaly "set resulttyoe to ~s~n" ty)
 `(set! resulttype ty)
  (fprintf anomaly "resEEulttyope now ~s~n" resulttype)

  (when group (fprintf anomaly "Too many groupss ~s ~s`n" group g))
 `(set! group g) #;(fprintf anomaly "proto had group ~s\n" g)
  ]
 [ _ (fprintf anomaly "; TODO: strange proto in command: ~s~n" command)]
 )] 
  [(cons 'param rest) (set! params (cons (parse-param (cast rest (Listof 
XML))) params))]
  [(list 'glx (list '@ (list 'type (? string? t)) (list 'opcode (? string? 
o
   (set! glxtype t)
   (set! opcode o)
   (fprintf anomaly "; LATER: whatever do i do with item ~s in command 
~s~n" item name)]
  [(list 'alias (list '@ (list 'name name)))
   (fprintf output "; alias for ~a~n" name)]
  [(list 'vecequiv (list '@ (list 'name name)))
   (fprintf anomaly "; LATER vecequiv ~s~n" item)]
   
  [ _ (fprintf anomaly "; TODO: unknown command item ~s~n" item) ]
  ))

  (when (null? name)
  #;(fprintf anomaly "; TODO: no name in command definition~n")
(fprintf anomaly "; TODO: best try:~n #;")
)

  (fprintf output "TODO: debug: Parameter list is ~s from command ~s~n" params 
command)
  (fprintf trace "; DEBUGG ~s~n" (map parameter-type params))
  (define args (params->ctypes params))
  (define results : (Listof (List Symbol ': TType)) (get-output-ctypes args)) ; 
parameters used as output variables
  (fprintf output "got results ~s from args ~s~n" results args)
;  (define rev-regular-type (cons '-> (map (lambda ([a :(List Boolean Symbol ': 
TType)]) (cdr a)) args))) ; <><><><>
  (define rev-regular-type
(cons '-> (map (ann cdr (-> (List Boolean Symbol ': TType) (List Symbol ': 
TType))) args))) ; <><><><>
  (fprintf output " resulttype ~s~n" resulttype)
  (define rev-type ; the type for the C ffi.
(if (null? results)
(cons resulttype rev-regular-type)
(cons (cons 'values
(cons 'result (map (lambda ([a : (List Symbol ': TType)]) 
(car a))
   (cast results (Listof (List Symbol ': 
TType)))
   )))
  (cons '-> (cons (list 'result ': resulttype) rev-regular-type))
  )
))
  (fprintf output "! rev-type ~s~n" rev-type)
  

Re: [racket-users] Do I misunderstand set! ?

2020-04-23 Thread Philip McGrath
I think you are running into the (very confusing!) issue Ben describes
here: https://groups.google.com/d/msg/racket-users/UD20HadJ9Ec/mDd4x8Y1BwAJ

-Philip


On Thu, Apr 23, 2020 at 5:00 PM Hendrik Boom  wrote:

> extract from code:
>
>   (fprintf anomaly "resEEEulttyope was ~s~n" resulttype)
>   (fprintf anomaly "set resulttyoe to ~s~n" ty)
>  `(set! resulttype ty)
>   (fprintf anomaly "resEEulttyope now ~s~n" resulttype)
>
> Previous creation of resulttype:
>
>   (define resulttype : (Option TType) #f) ; TODO: check there's only one
>
> Output that appeared on the anomaly file:
>
> resEEEulttyope was #f
> set resulttyoe to _void
> resEEulttyope now #f
>
> I stuck the E's in just to make sure these were the statements really
> generating that output.
>
> If I am correct, the set! should have changed the value of resulttype.
> I'm doing thie in typed-racket.
>
> -- hendrik
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/racket-users/20200423210026.3iuntiq3jqyjtpmc%40topoi.pooq.com
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/CAH3z3gbZqM4i1V_Cowzd8ewfpVZS9po5oUqXnw81BARMaJfnUg%40mail.gmail.com.


[racket-users] Do I misunderstand set! ?

2020-04-23 Thread Hendrik Boom
extract from code:

  (fprintf anomaly "resEEEulttyope was ~s~n" resulttype)
  (fprintf anomaly "set resulttyoe to ~s~n" ty)
 `(set! resulttype ty)
  (fprintf anomaly "resEEulttyope now ~s~n" resulttype)

Previous creation of resulttype:

  (define resulttype : (Option TType) #f) ; TODO: check there's only one

Output that appeared on the anomaly file:

resEEEulttyope was #f
set resulttyoe to _void
resEEulttyope now #f

I stuck the E's in just to make sure these were the statements really 
generating that output.

If I am correct, the set! should have changed the value of resulttype.
I'm doing thie in typed-racket.

-- hendrik

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/20200423210026.3iuntiq3jqyjtpmc%40topoi.pooq.com.