Re: [racket-users] Struct declaration conflict if a file is required implicitly

2017-07-23 Thread Alejandro Sanchez
Thank you so much! I feel so stupid now, that file path is a leftover from when 
the directory structure was different. Now it works perfectly.

> On 23 Jul 2017, at 17:43, Ryan Culpepper  wrote:
> 
> On 07/23/2017 07:26 AM, Alejandro Sanchez wrote:
>> Hello everyone,
>> I am working on this project: https://gitlab.com/HiPhish/MsgPack.rkt/
>> I am writing test cases and I ran into a problem with my ‘ext’ structure. It 
>> is declared in the file ‘msgpack/main.rkt’, which is required in the file 
>> ‘msgpack/pack.rkt’ (also in ‘msgpack/unpack.rkt’). For my test case the test 
>> file looks like this:
> 
> It looks like msgpack/pack.rkt requires "../main.rkt" rather than "main.rkt". 
> There isn't a "../main.rkt" checked in, so maybe you have a stale file 
> getting loaded? (It could be at "../main.rkt" or possibly 
> "../compiled/main_rkt.zo".)
> 
> Ryan

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Struct declaration conflict if a file is required implicitly

2017-07-23 Thread hiphish
On Sunday, July 23, 2017 at 5:43:51 PM UTC+2, Ryan Culpepper wrote:
> On 07/23/2017 07:26 AM, Alejandro Sanchez wrote:
> > Hello everyone,
> > 
> > I am working on this project: https://gitlab.com/HiPhish/MsgPack.rkt/
> > 
> > I am writing test cases and I ran into a problem with my ‘ext’ structure. 
> > It is declared in the file ‘msgpack/main.rkt’, which is required in the 
> > file ‘msgpack/pack.rkt’ (also in ‘msgpack/unpack.rkt’). For my test case 
> > the test file looks like this:
> 
> It looks like msgpack/pack.rkt requires "../main.rkt" rather than 
> "main.rkt". There isn't a "../main.rkt" checked in, so maybe you have a 
> stale file getting loaded? (It could be at "../main.rkt" or possibly 
> "../compiled/main_rkt.zo".)
> 
> Ryan

Thank you so much! I feel so stupid now, that file path is a leftover from when 
the directory structure was different. Now it works perfectly.

-- 
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.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Struct declaration conflict if a file is required implicitly

2017-07-23 Thread Ryan Culpepper

On 07/23/2017 07:26 AM, Alejandro Sanchez wrote:

Hello everyone,

I am working on this project: https://gitlab.com/HiPhish/MsgPack.rkt/

I am writing test cases and I ran into a problem with my ‘ext’ structure. It is 
declared in the file ‘msgpack/main.rkt’, which is required in the file 
‘msgpack/pack.rkt’ (also in ‘msgpack/unpack.rkt’). For my test case the test 
file looks like this:


It looks like msgpack/pack.rkt requires "../main.rkt" rather than 
"main.rkt". There isn't a "../main.rkt" checked in, so maybe you have a 
stale file getting loaded? (It could be at "../main.rkt" or possibly 
"../compiled/main_rkt.zo".)


Ryan

--
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.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Struct declaration conflict if a file is required implicitly

2017-07-23 Thread Alejandro Sanchez
Hello everyone,

I am working on this project: https://gitlab.com/HiPhish/MsgPack.rkt/

I am writing test cases and I ran into a problem with my ‘ext’ structure. It is 
declared in the file ‘msgpack/main.rkt’, which is required in the file 
‘msgpack/pack.rkt’ (also in ‘msgpack/unpack.rkt’). For my test case the test 
file looks like this:

(require
  quickcheck
  rackunit/quickcheck
  (file "../../msgpack/main.rkt")
  (file "../../msgpack/pack.rkt"))

(check-property
  (property ()
(let ([obj (ext #x01 (bytes #x02))])
  (bytes=? (call-with-output-bytes (λ (out) (pack obj out)))
   (bytes-append (bytes #xD4 (ext-type obj))
 (ext-data obj))

Here is what happens from my understanding: when I required ‘main.rkt’ the 
structure declaration got evaluated, creating all the functions that go along 
with it, including ‘ext’ and ‘ext?’. Then when I required the ‘pack.rkt’ file 
those declarations got evaluated again and created a new set of ext-related 
functions that just happen to have the same name. This is why I  the object I’m 
trying to pack falls through all the ‘cont’ cases.

This isn’t limited to the test file, I also tried the following on the REPL 
with the same results:

Welcome to Racket v6.9.
> (require msgpack msgpack/pack)
> (define e (ext 1 (bytes 2 3)))
> (define out (open-output-bytes))
> (pack e out)
; Type not supported by MessagePack [,bt for context]
> (pack-ext e out)
; pack-ext: contract violation
;   expected: ext?
;   given: #
;   in: the 1st argument of
;   (->
;ext?
;(and/c output-port? (not/c port-closed?))
;any)
;   contract from:
;   /msgpack-rkt/msgpack/pack.rkt
;   blaming: top-level
;(assuming the contract is correct)
;   at: /msgpack-rkt/msgpack/pack.rkt:53.5
; [,bt for context]
> ,bt
; pack-ext: contract violation
;   expected: ext?
;   given: #
;   in: the 1st argument of
;   (->
;ext?
;(and/c output-port? (not/c port-closed?))
;any)
;   contract from:
;   /msgpack-rkt/msgpack/pack.rkt
;   blaming: top-level
;(assuming the contract is correct)
;   at: /msgpack-rkt/msgpack/pack.rkt:53.5
;   context...:
;
/usr/local/Cellar/minimal-racket/6.9/share/racket/collects/racket/contract/private/blame.rkt:159:0:
 raise-blame-error16
;
/usr/local/Cellar/minimal-racket/6.9/share/racket/collects/racket/contract/private/arrow-val-first.rkt:357:18
;
/usr/local/Cellar/minimal-racket/6.9/share/racket/pkgs/xrepl-lib/xrepl/xrepl.rkt:1448:0
;
/usr/local/Cellar/minimal-racket/6.9/share/racket/collects/racket/private/misc.rkt:88:7
>

Adding a ‘#:prefab’ to the end of the struct declaration does not solve the 
problem. What am I doing wrong? Both the packing and unpacking need the ‘ext’ 
type for conformance with MessagePack. Do I have to make a large umbrella 
module that provides the entire API? I would prefer is users could just 
‘require’ parts of the library as they need them (i.e. only ‘(require 
msgpack/pack)’ if you only want to unpack data).

-- 
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.
For more options, visit https://groups.google.com/d/optout.