Re: [racket] current-module-name-resolver and syntax/docprovide

2014-06-05 Thread Matthew Flatt
At Thu, 5 Jun 2014 16:15:26 -0400, Greg Hendershott wrote: > After stumbling across the syntax/docprovide module [...] > > To back up a step: Is syntax/docprovide something that is intended to > be used these days? No. It was a very early experiment. Like so many early Racket experiments, it was

Re: [racket] How to get arity of make-object? Found answer

2014-06-05 Thread Matthew Flatt
Sorry for being so late to the discussion, but I agree that something like `class-constructor-arity` and `class-constructor-arity-includes?` should be added to `racket/class`. At Fri, 06 Jun 2014 05:24:36 +0400, Roman Klochkov wrote: > Hm... But reading it's sources give me some clues. > > Now I

Re: [racket] How to get arity of make-object? Found answer

2014-06-05 Thread Roman Klochkov
Hm... But reading it's sources give me some clues. Now I have working dirty hack #lang racket/base (require racket/private/class-internal) (define (class-inits cls)   (apply append     (for/list ([c (in-vector (class-supers cls))])       (class-init-args c It gives the list of class init

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Matthias Felleisen
class/c doesn't check inits properly: > #lang racket > > (provide > (contract-out > [c% (class/c (init-field [x number?]))])) > > (define c% > (class object% > (field (x 10)) > (super-new))) and now run > Welcome to Racket v6.0.1.12. > > (require "foo.rkt") > > (new c%) > (o

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Roman Klochkov
It is maybe closer. But inside define-binary-class I also doesn't know the total number of init arguments. Because library user may give any superclass. And I don't know, how to get init arguments (or arity for of make-object for a given class) without calling make-object and reading the error

Re: [racket] Creating a module language extending typed/racket

2014-06-05 Thread Alexander D. Knauth
This works: (module testlang racket/base (require typed/racket) (provide (all-from-out typed/racket)) ) I have no idea why the other one doesn’t though. On Jun 5, 2014, at 3:59 PM, Michael Ballantyne wrote: > Hey all, > I'd like to switch a module language I've created and the code wri

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Matthias Felleisen
Sorry I am so slow. Contracts are first-class values. You could modify define-binary-class so that it also creates and defines a contract P that can be passed along to read-object. Then read-object can use P like this: > #lang racket > > (provide > a% a? > b% b? > (contract-out >

[racket] current-module-name-resolver and syntax/docprovide

2014-06-05 Thread Greg Hendershott
After stumbling across the syntax/docprovide module in the documentation, and trying to use it, I discovered this error: #lang racket/base (require syntax/docprovide) (let ([orig-resolver (current-module-name-resolver)]) (parameterize ([current-module-name-resolver (case-lambda

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Roman Klochkov
I don't create classes. I provide a function read-object, so user can do (require binary-class) (define base% (class (super-new) (init-field param1 param2))) (define-binary-class db base% ((a u1) (b u2))) (define data (read-object db my-file data-param1 data-param2) And I try to make a contract

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Matthias Felleisen
Can't you use is-a?/c like this: > #lang racket > > (provide > a% > b% > (contract-out > (read-object (case-> > [-> (is-a?/c a%) number? number?] > [-> (is-a?/c b%) number? number? number?] > > (define a% (class object% (super-new))) > (define b%

[racket] Creating a module language extending typed/racket

2014-06-05 Thread Michael Ballantyne
Hey all, I'd like to switch a module language I've created and the code written in it to typed racket. I can't figure out how to reexport all the typed/racket bindings like I can for normal racket, though. If I try this in the repl: (module testlang typed/racket (provide (all-from-out typed/racket

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Roman Klochkov
(define (read-object binary-class in . args)   (send (apply make-object binary-class args) read in)) read-object takes a class as a first arg, and additional arguments to make an object of that class. I can't make case-> because I don't know j,ject of what (user-defined) class will be created 

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Matthias Felleisen
From what I understand now, you want a contract for a function that creates objects from a variable number of arguments. If you write your module interface like this, > #lang racket > > (provide > (contract-out > (read-object (case-> > [-> 'a number? number?] >

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Matthias Felleisen
Got it. You have binary data in 'files' and you want to directly generate an object from them. You will need a case-by-case contract with dependencies. That's doable -- Matthias (ran off to meeting) On Jun 5, 2014, at 1:41 PM, Roman Klochkov wrote: > It is not writing, but reading. I'm ma

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Roman Klochkov
It is not writing, but reading. I'm making uinversal library for binary data (like dbf, mp3 id3 tags, and so on)  mapping to objects https://github.com/Kalimehtar/binary-class read-object simply ( define ( read-object binary-class in . args ) ( send ( apply make-object binary-class args

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Matthias Felleisen
Do you control the writing of objects to a port? If so, check out 'serialization.' If not, I don't think I can help you. Sorry -- Matthias On Jun 5, 2014, at 12:29 PM, Roman Klochkov wrote: > I don't control class creation. > I need to make a wrapper around make-object and attach contract to

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Roman Klochkov
I don't control class creation. I need to make a wrapper around make-object and attach contract to the wrapper. Now I have (provide/contract   [ read-object ( ->i ([ binary-class ( implementation?/c binary<%> )]     [ port input-port? ])     #:rest [ args

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Alexander D. Knauth
I’m just wondering, would it be possible to make a class be a function that would be equivalent to (make-object % arg …)? Is there a way to attach structure-type properties to classes, instead of to instances of classes? Because if there is, then procedure-arity could work on the class.

Re: [racket] How to get arity of make-object?

2014-06-05 Thread Matthias Felleisen
Here is the pattern I recommend: Welcome to Racket v6.0.1.11. > (define (create-c #:x [x 0]) (new c% [x x])) > (define c% (class object% (init-field x) (super-new))) That is, a class comes with a 'factory' definition, a function that creates instances and uses keywords similar to those used by

[racket] How to get arity of make-object?

2014-06-05 Thread Roman Klochkov
For any procedure I can use procedure-arity. But how to get the number of init arguments for a class? Or maybe there are any other way to make a contract, like in Guide 7.3.9, where one can compare number of arguments and arity of the function, but when using (make-object someclass ...) instea

Re: [racket] AutoCAD, AutoLISP, MzCOM and Racket

2014-06-05 Thread Matthew Flatt
Are you running both 32-bit AutoCAD and MzCOM, or both 64-bit AutoCAD and MzCOM? If you run mzcom.exe /RegServer /v do you get any errors (in a dialog box)? At Thu, 5 Jun 2014 18:12:25 +1000, "Tim Marchbank" wrote: > Hi, > > I have been programming in AutoLISP inside AutoCAD for a while now

[racket] AutoCAD, AutoLISP, MzCOM and Racket

2014-06-05 Thread Tim Marchbank
Hi, I have been programming in AutoLISP inside AutoCAD for a while now and also have done a bit of programming with Racket, including dialog boxes. Recently I tried to use COM from inside Racket to run AutoCAD and got that to work. However, now I am attempting to use Racket as a COM object (usin