[racket-users] Re: Racket News - Issue 37

2020-08-24 Thread Deren Dohoda
Hi Paulo,

The link to the slack community is munged with the racket-news URL.

Deren

On Monday, August 24, 2020 at 2:23:59 PM UTC-4 Paulo Matos wrote:

> It's here! :)
> https://racket-news.com/2020/08/racket-news-issue-37.html
>
> Enjoy.
>
> Paulo Matos
>

-- 
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/18be788c-7a3b-4b34-94e9-4f85c14ee92an%40googlegroups.com.


Re: [racket-users] Re: Application Templates!

2020-08-20 Thread Deren Dohoda
> I think Racket would benefit by a suite of applications which are small 
but 
> not trivial and with a source code which is commented in more detail than 
a 
> regular application 
I would kill to understand the intended use of the framework library. I 
don't understand what I'm supposed to do with it at all. Does anyone have 
an application written with framework that I can look at? Or could we make 
a small template with some framework features like autosave which are quite 
unique to framework over racket/gui? I feel very stupid asking but my 
desire to try it has exceeded my embarrassment in this regard.

Deren

-- 
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/c754b4a3-9073-4ecd-9815-7491ad96cf89n%40googlegroups.com.


[racket-users] Package Server Update Status

2020-08-18 Thread Deren Dohoda
Hi team,

I notice on the very nice about page, 
https://pkg-build.racket-lang.org/about.html, it does not give an 
indication of when packages are rebuilt. I had a package that had doc 
problems and conflicts that I resolved (the ol' manual.scrbl curse). It 
appeared from me browsing information on a few packages that things were 
rebuilt approximately once per week but it has now been over a week. The 
status seems to indicate that a fresh package was noticed on my repository 
but it hasn't been reflected in the build.

Is there a problem with the server at the moment or am I simply being 
impatient?

Thanks,
Deren

-- 
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/63c0a0eb-c797-49a1-8cf6-020e774e3833n%40googlegroups.com.


[racket-users] Re: Help creating a distributable version of my app

2020-08-17 Thread Deren Dohoda
Hello,

The main submodule is intended to be a way to have execution when run from 
racket/drracket. Maybe there is a way to use ++lib or ++named-lib flags to 
raco exe but I can't tell from the docs. I just removed your (module+ main 
...) wrapper and used the default tool settings from DrRacket and it works 
fine. So you might consider a separate file which isn't "main" which 
doesn't have this wrapper simply for distribution packaging purposes.

Regards,
Deren

On Monday, August 17, 2020 at 12:53:27 PM UTC-4 an...@andregarzia.com wrote:

> Good afternoon friends,
>
> I'm trying to build a distributable version of my little Gemini browser:
>
>   https://git.sr.ht/~soapdog/fafi-browser
>
> The source folder contains a `main.rkt` which has `(module+ main ...)` in 
> it. I thought that selecting that file and using the menu to create a 
> distribution should work. I also tried to come up with a build script based 
> on Alex build script for ActivityLog2:
>
>   https://git.sr.ht/~soapdog/fafi-browser/tree/maybe-build/build.rkt
>
> What is happening is that everything appears to build correctly on first 
> glance but nothing happens when I try running the `Fafi.exe` file. If I try 
> running it like `Fafi.exe -v` I get a `Racket v7.7` banner which makes me 
> think that my main module is not executing. This happens if I use my build 
> script or if I use the menu in DrRacket.
>
> Can someone share some pointers or feedback about where to look to fix 
> this? I greatly appreciate any feedback.
>
> Kind regards
> A.
>
> -- 
> https://www.andregarzia.com 
> Want to support me? Buy me a coffee at https://ko-fi.com/andregarzia
>

-- 
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/1d8e4cf3-e286-4827-91d4-367b453597a3n%40googlegroups.com.


Re: [racket-users] Scribble and examples can't read racket-prefs.rktd

2020-08-16 Thread Deren Dohoda
Thank you Matthew, that did resolve the problem, though I was unable to 
ever determine why I could not display a plot from plot/pict. It seems that 
it was somehow related to (sandbox-output 'string) which could never be 
coerced display a bitmap, pict, etc. Ultimately I just used 
(make-base-eval) instead and skipped the sandbox.

Deren

On Sunday, August 16, 2020 at 8:06:49 AM UTC-4 Matthew Flatt wrote:

> Sandboxed filesystem and unsafety access is too strict for many
> purposes. For documentation, I recommend using a trusted sandbox by
> wrapping the sanebox creation with
> `call-with-trusted-sandbox-configuration`.
>
> Matthew
>
> At Sun, 16 Aug 2020 00:45:46 -0700 (PDT), Deren Dohoda wrote:
> > Hi Racketeers,
> > 
> > I'm going in absolute circles trying to understand what I might be doing 
> > wrong. I can use the command line scribble to generate html, which works 
> > fine except a problem showing # instead of an actual plot/pict 
> image. 
> > And for that matter the package installs fine using a local install. But 
> > trying to run the scribble file in DrRacket always gives me errors like 
> > "cannot read racket-prefs.rkt" or other errors like "cannot reference an 
> > identifier without a definition" and sometimes it will give me errors 
> like 
> > I have used (protect-out ...) somewhere but I am definitely not as I 
> didn't 
> > even learn about this kind of provide until I saw this error.
> > 
> > Does anyone using Windows have experience getting rid of this message or 
> > have an idea what I might be doing wrong? I have a feeling that this 
> > message isn't actually the problem and it's something to do with sandbox 
> > somehow.
> > 
> > @(define this-eval (parameterize ((sandbox-output 'string)
> > (sandbox-error-output 'string)
> > (sandbox-memory-limit 100))
> > (make-evaluator 'racket/base #:requires '("main.rkt" 
> > "fit.rkt" plot/pict)
> > (print-as-expression #f) 
> > )))
> > 
> > Thanks,
> > Deren
>

-- 
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/6852ab0a-ceb4-4799-b842-657582755747n%40googlegroups.com.


[racket-users] Scribble and examples can't read racket-prefs.rktd

2020-08-16 Thread Deren Dohoda
Hi Racketeers,

I'm going in absolute circles trying to understand what I might be doing 
wrong. I can use the command line scribble to generate html, which works 
fine except a problem showing # instead of an actual plot/pict image. 
And for that matter the package installs fine using a local install. But 
trying to run the scribble file in DrRacket always gives me errors like 
"cannot read racket-prefs.rkt" or other errors like "cannot reference an 
identifier without a definition" and sometimes it will give me errors like 
I have used (protect-out ...) somewhere but I am definitely not as I didn't 
even learn about this kind of provide until I saw this error.

Does anyone using Windows have experience getting rid of this message or 
have an idea what I might be doing wrong? I have a feeling that this 
message isn't actually the problem and it's something to do with sandbox 
somehow.

@(define this-eval (parameterize ((sandbox-output 'string)
  (sandbox-error-output 'string)
  (sandbox-memory-limit 100))
 (make-evaluator 'racket/base #:requires '("main.rkt" 
"fit.rkt" plot/pict)
 (print-as-expression #f) 
 )))

Thanks,
Deren

-- 
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/bb013d47-3f7b-4eb2-979a-a5c55e4b5b3dn%40googlegroups.com.


Re: [racket-users] Scribble and structs

2020-08-12 Thread Deren Dohoda
Solved some of which was offline.

First was my misunderstanding about having to document implied procedures
when using a struct. Second was that I missed a parameter
print-as-expression which should be parameterized as #f for the evaluator.

Thanks everyone!
Deren

On Wed, Aug 12, 2020, 7:08 AM Deren Dohoda  wrote:

> Hi racketeers,
>
> I have two questions. The first is: is there a way to have scribble /
> sandbox use the gen:custom-write property of a structure? When I use
> @examples the output is just the bare structure output, not using the
> gen:custom-write procedure.
>
> Second, I am working on a very simple polynomial library using 7.7 and
> during the creation of the docs I receive this warning:
> "WARNING: collected information for key multiple times: '(dep ((lib
> "simple-polynomial/main.rkt") polynomial?)); values: #t #t"
> among other similar warnings all seeming to point to the procedure
> polynomial?.
>
> This would lead me to believe I have somehow required or defined things
> multiple times. However my "main.rkt" is just a one file require and an
> all-from-out. The underlying library does not use (provide (struct-out
> ...)), I only (provide polynomial?).
>
> Do structs somehow mess with scribble here? A small search reveals only a
> single posting from the developers library with the comment "fix your
> library." Love to, but what's the problem?
>
> Thanks for any thoughts,
> Deren
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Racket Users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/racket-users/oKtKqyQZDg4/unsubscribe.
> To unsubscribe from this group and all its topics, 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/2ffd6a24-8437-4a7e-b688-74135a866673n%40googlegroups.com
> <https://groups.google.com/d/msgid/racket-users/2ffd6a24-8437-4a7e-b688-74135a866673n%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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/CAE-rtpnj5U8AG3yRYir5oMvHbHq9s0SfN9x-UYL29v4Rp-Fi-A%40mail.gmail.com.


Re: [racket-users] Scribble and structs

2020-08-12 Thread Deren Dohoda
Hi Matthew,

> A `@defstruct*[polynomial .]` form does document `polynomial?`.
> Although the word `polynomial?` doesn't appear on the page, it's
> implied by the `struct` form on the page.

Thank you, I understand.

Deren

-- 
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/CAE-rtpm4SRSpBWNDfv1rCKJgc7bzpkFithao%2BB7U1R6200UEkQ%40mail.gmail.com.


Re: [racket-users] Scribble and structs

2020-08-12 Thread Deren Dohoda
Hi Matthew,

Structs should not cause any particular problem for Scribble. I'm
> puzzled by the problem with `gen:custom-write`, because that should
> certainly work with sandboxes and `@examples`.

I will try to look at some included documents with the main distribution to
see if I can figure out what I'm doing wrong then.

The "collected information multiple times" error would be caused by
> multiple declarations of `polynominal?` in the docs, as opposed to
> multiple definitions in the code. Depending on when the error happens,
> though, it could be due to multiple instances of a whole document, as
> Laurent suggests.
>
If I remove the @defproc of polynomial? then I do not get the error, though
then of course that definition never appears in the document. However, if I
instead remove the @defstruct* then the error also disappears. But
@defstruct* does not document the automatically generated procedure so it
seems that it shouldn't introduce it as far as scribble is concerned. Is
this a bug?

Deren

-- 
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/CAE-rtpn9E_Qz78vi8FCbKkKKfugk-eWEgjo%2ByHn-raGO5Hu7rg%40mail.gmail.com.


[racket-users] Scribble and structs

2020-08-12 Thread Deren Dohoda
Hi racketeers,

I have two questions. The first is: is there a way to have scribble / 
sandbox use the gen:custom-write property of a structure? When I use 
@examples the output is just the bare structure output, not using the 
gen:custom-write procedure.

Second, I am working on a very simple polynomial library using 7.7 and 
during the creation of the docs I receive this warning:
"WARNING: collected information for key multiple times: '(dep ((lib 
"simple-polynomial/main.rkt") polynomial?)); values: #t #t"
among other similar warnings all seeming to point to the procedure 
polynomial?.

This would lead me to believe I have somehow required or defined things 
multiple times. However my "main.rkt" is just a one file require and an 
all-from-out. The underlying library does not use (provide (struct-out 
...)), I only (provide polynomial?). 

Do structs somehow mess with scribble here? A small search reveals only a 
single posting from the developers library with the comment "fix your 
library." Love to, but what's the problem? 

Thanks for any thoughts,
Deren

-- 
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/2ffd6a24-8437-4a7e-b688-74135a866673n%40googlegroups.com.


Re: [racket-users] Licence guidance

2018-09-26 Thread Deren Dohoda
I put a package up but it has no license info in the code. I would add one
which is the most permissive possible that wouldn't cause conflict. I guess
this is BSD? MIT?

On Tue, Sep 25, 2018, 12:30 PM Neil Van Dyke  wrote:

> BTW, I don't know the status of possible new GPL and LGPL versions in
> progress, but, if any Racket people have some insights into how to
> improve the "linking" concepts or some other aspect, in the spirit of
> FSF goals, the FSF has seemed open to comments.  If you don't know who
> else to contact, you can always email RMS.
>
> You can get as technical as necessary.  Organizationally, besides the
> FSF being founded by and attracting some high-powered techies, some
> advisors are very noteworthy Scheme people.  Also, a Scheme with
> multiple `#lang`s (though it wasn't called `#lang`) was actually a
> central part of the GNU roadmap, from early on.  (And probably would've
> been in popular use atop Linux for over a decade now, but for another
> party's business decision, outside of FSF's control, not a technical or
> acceptance reason.)
>
> --
> 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.
>

-- 
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] Call to C++ files / or functions from Racket?

2018-08-18 Thread Deren Dohoda
Hi David. You want to either look at the documentation of racket/system (to
open executables) or ffi/unsafe (for shared libraries with a C interface).

Deren

On Sat, Aug 18, 2018 at 1:21 PM, David Merinos  wrote:

> Hello. Is there a way to call to a C program from within racket? I'd like
> to write a few Racket functions to call CGAL programs I made on C++. Thank
> you.
>
> --
> 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.
>

-- 
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] Question about style

2018-08-16 Thread Deren Dohoda
>
> Thanks for the up-vote but let me explain the “local” rationale here and
> vote for the ‘inner define’ variant.
> [snip]...
>
>
> In Racket programs for the world, possibly real, you want to avoid
> rightward drift. Indenting deeper and deeper makes code appear ‘ugly’ to
> many eyes, especially those used to other languages. But I will say this is
> also the one point about ‘ugly’-syntax languages that I have learned to
> appreciate (plus some concision in names).
>
> Internal defines are thus much more preferable than local, let, letrec,
> and similar constructs. See the Style Guide, where I spelled this out in a
> bit more detail.
>

In general cases I agree with this and view heavy indenting as at a minimum
code smell but 'let' is so conceptually simple to work with syntactically.
If I want to extend/alter/make an analogous construction of 'let' it's
three to twenty lines depending on what I'm doing. I have no clue how to
start messing with internal definitions in a similar way.

Deren

-- 
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] Question about style

2018-08-11 Thread Deren Dohoda
>
>
>
> My question is: is the way I'm writing things considered to be bad
> style?  It feels like a hangover from more imperative-style programming
> & the inclination to do one thing "per line".  On the other hand, it
> often helps readability.
>

I invariably write my code like this. I just think it's easier to
understand two years later. I have a few let-like macros for this reason.
1) print-let /print-let*, for printf-debugging of let forms. 2) andlet /
andlet*, for stopping binding evaluation in a let when the value to bind is
#f (then the whole 'let' expression is #f). Sometimes I use internal
'define's instead, based on feel for heavily-indented code. I rarely try to
write a complicated expression directly without some kind of explanatory
setup. I have tinkered with some other 'let'-like forms but these two in
particular are really useful.

Deren

-- 
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] raco distribute help

2018-02-01 Thread Deren Dohoda
Hi everyone,

I'm having a hard time understanding the docs for raco exe and raco
distribute.

tl;dr main.rkt has to (dynamic-require user-selected.rkt) and
user-selected.rkt is written in a different #lang and requires a file from
this program. How do I glue these pieces together for raco exe / raco
distribute?

My program has two things which seem to be hanging me up. The first is that
a file is grabbed with (dynamic-require) based on a path obtained by the
user with (get-file ...). This file is written in a different #lang and
uses (require ...) for some syntax transformers.

The exe builds alright but chokes when used because it can't find the #lang
and can't find the (require ...).

Ideally the file which is given to (dynamic-require ...) could be in any
folder the user chooses, but then the (require ...) statement would be all
over the map and I don't understand what I'm supposed to do to resolve
this. If it helps, the file is already required by the program and isn't
used only by the user-selected file. ++copy-collects doesn't seem to grab
#lang folders correctly or I don't understand how to use it.

Can someone give me some guidance here?

Thanks,
Deren

-- 
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] in-source documentation, single-file packages, and scribble/srcdoc

2018-01-27 Thread Deren Dohoda
Neil,

If I understand the implication: how is turbo-racket practically different
from scribble/lp2? —Just that the code is not put in the document?

Deren

On Sat, Jan 27, 2018 at 7:26 AM, Neil Van Dyke  wrote:

> 1. Do we foresee using srcdoc for new work in the future, and is it
> suitable as part of a backend for other in-source documentation?
>
> 2. What do people think of writing reusable modules approximately like the
> example below?  Is that something you'd want to do?
>
> (The basic idea is that you usually have one source file per module, which
> is self-contained, with polished and up-to-date documentation and unit
> tests and such, and is generally written and maintained as if it is reused
> or could be reused as its own package at any time. All this, in a fairly
> "lightweight" form, although we acknowledge that the below example is a big
> bureucratic load for two one-line procedures, but maybe it is practical for
> most real-world modules.)
>
> (For this example, I used capitalized names, to avoid confusing with
> familiar names, but some other names that weren't capitalized might also
> work.  Note that some forms are dual-purpose; for example, `Proc` turns
> into something like a Scribble `defproc` and a Racket code `define`,
> `provide`, and a contract somewhere.  Note that I'm intentionally putting
> `KnownIssues` and `History` into the source file, in a lightweight and
> self-contained kind of way, but those forms could be optional, for
> people/projects that prefer to use separate issue-tracking and release
> notes.  Also note that, if `Package` weren't present here, you could
> imagine this module being part of a multi-module package, including
> documentation that is incorporated by reference into a bigger document,
> but, by default, we want to encourage lightweight reusable modules.}
>
>  BEGIN 
>
> #lang turbo-racket
>
> @Package[
> @Name{foo}
> @Version{1.1}
> @Web{http://www.example.com/foo/}
> @Authors{Jane Doe}
> @Legal{Copyright 2025 Jane Doe. You may blah blah blah
>blah blah blah.}]
>
> (Require (bunny :version "1.2+")
>  (puppy :url "https://git.example.com/release/2.0/puppy.rkt;
> :sha256 "347ab429830..."))
>
> @Section{Introduction}
>
> @Doc{This package provides a @racket{foo} and @racket{bar},
>  for all your fooing and anti-fooing needs.}
>
> @Doc{For example, you could do:
>
>  ...
>
>  and it would totally work, dude.}
>
> @Section{Main Interface}
>
> @Doc{The interface is just two procedures.}
>
> (Proc (foo (x real?) (y real))
>  real?
>   @Doc{This returns a foo of @var{x} and @var{y}.
>It's really quite neat.}
>   (* x y x y x y))
>
> (Tests (test (foo 1 2) 666)
>(test (foo 3 4) 42))
>
> (Proc (bar (x real?) (y real))
>  real?
>   @Doc{We don't know why anyone would want to do this,
>but the customer is always right.}
>   (+ x y x y x y))
>
> (Tests (test (bar 0 0) 0)
>(test (bar 1999 1999) 0))
>
> @Section{Conveniences}
>
> ...
>
> @Section{Quantum Theory}
>
> @Doc{Perhaps a discussion is in order.
>
>  ...}
>
> @KnownIssues[
>
> @item{Not everyone yet fooifies.}
>
> @item{Fix intermittent explosions.}]}
>
> @History[
>
> @Release["1.1" "2025-12-25"]{
> @itemize[
> @item{Reversed behavior of @racket{foo} and @racket{bar}.}
> @item{Documented explosion issue.}]}
>
> @Release["1.0" "2025-12-24"]{
> This was a good initial release.  We got out there,
> and gave 110%.}]}
>
>  END 
>
> --
> 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.
>

-- 
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] A very simple #lang

2018-01-25 Thread Deren Dohoda
Thanks Philip, of course I should have checked for something like this
directly.

Deren

On Thu, Jan 25, 2018 at 3:51 PM, Philip McGrath <phi...@philipmcgrath.com>
wrote:

> You may just want to use #lang exact-decimal racket (see:
> http://docs.racket-lang.org/exact-decimal-lang/index.html).
>
> I have encountered a similar problem with six arguments to read-syntax
> before, and I remember there being a good reason that was explained in some
> obscure corner of the documentation, but I don't remember exactly what the
> reason was, and I'm not immediately finding it in the documentation, which
> perhaps suggests that, whatever the reason is, it should be documented more
> prominently.
>
> -Philip
>
> On Thu, Jan 25, 2018 at 2:21 PM, Deren Dohoda <deren.doh...@gmail.com>
> wrote:
>
>> Hi everyone,
>>
>> I am desperately in need of a #lang exact so that decimals are read as
>> exact values.
>>
>> I thought this would be extremely simple:
>> ..\exact\lang\reader.rkt
>>
>> (module reader racket/base
>>   (provide (rename-out (exact-read read)
>>(exact-read-syntax read-syntax)))
>>   (require (rename-in racket/base (read base:read) (read-syntax
>> base:read-syntax)))
>>   (define (exact-read . in)
>> (parameterize ((read-decimal-as-inexact #f))
>>   (apply base:read in)))
>>   (define (exact-read-syntax . in)
>> (parameterize ((read-decimal-as-inexact #f))
>>   (apply base:read-syntax in​
>> ;;
>> It installs alright, though chokes on building docs for some reason, but
>> then when I attempt to use it:
>> ..\exact\lang\reader.rkt:13:6: read-syntax: arity mismatch;
>>  the expected number of arguments does not match the given number
>>   expected: 0 to 2
>>   given: 6
>>   arguments...:
>>
>> Why is read-syntax getting six arguments?
>>
>> Deren
>>
>> --
>> 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.
>>
>
>

-- 
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] A very simple #lang

2018-01-25 Thread Deren Dohoda
Hi everyone,

I am desperately in need of a #lang exact so that decimals are read as
exact values.

I thought this would be extremely simple:
..\exact\lang\reader.rkt

(module reader racket/base
  (provide (rename-out (exact-read read)
   (exact-read-syntax read-syntax)))
  (require (rename-in racket/base (read base:read) (read-syntax
base:read-syntax)))
  (define (exact-read . in)
(parameterize ((read-decimal-as-inexact #f))
  (apply base:read in)))
  (define (exact-read-syntax . in)
(parameterize ((read-decimal-as-inexact #f))
  (apply base:read-syntax in​
;;
It installs alright, though chokes on building docs for some reason, but
then when I attempt to use it:
..\exact\lang\reader.rkt:13:6: read-syntax: arity mismatch;
 the expected number of arguments does not match the given number
  expected: 0 to 2
  given: 6
  arguments...:

Why is read-syntax getting six arguments?

Deren

-- 
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] How to delay evaluation of a set! expression

2017-12-21 Thread Deren Dohoda
Vityou,

> even though (class ...) expands into a function where method-list is
defined.

It does not expand into a function where method-list is defined because it
does not expand in that way. The macro "define/method" is called with the
given syntax and the macro operates on that syntax (it's just a procedure
that takes a syntax argument and evaluates to syntax) and where the macro
lives, "method-list" is neither defined nor given as part of use of the
syntax. So the macro introduces it's own "method-list", so something in the
background like "method-list7734", which isn't your "method-list" but since
the macro's own "method-list" doesn't exist, set! doesn't know what to do,
and you get an error. This is a combination of how procedures work and how
hygiene works in macros.

One way to manage this is to make it part of the syntax:
;
(define-syntax (define/method stx)
  (syntax-parse stx
[(_ (name ML arg ...) body)
 #'(begin (define (name arg ...) body)
  (set! ML (cons `(name ,name) ML)))]))

(define (make-person name age)
  (define (obj arg)
(define method-list '())
(define/method (get-name method-list) name)
(second (assq arg method-list)))
  obj)
;
Then it expands as you expect, because it's operating on the syntax you
have given it.

Another way: the macro can be coerced to use an identifier which it doesn't
understand by breaking the hygiene barrier

;
define-syntax (define/method stx)
  (syntax-parse stx
[(_ (name arg ...) body)
 (with-syntax ((ML (datum->syntax stx 'method-list)))
#'(begin (define (name arg ...) body)
 (set! ML (cons `(name ,name) ML]))
;
Now this macro assumes the identifier "method-list" exists in whatever
context the code expands in, which is the behavior you expect.

Normally we don't want to break hygiene. For instance, if a macro's code
introduced some temporaries like "num" or "x" or something, we wouldn't
want those temporaries to shadow or otherwise clobber some innocent
macro-user's own use of these identifiers. When we call a procedure like
"displayln" we don't need to worry that the author of the code used some
name for some local identifier. Since macros are just racket procedures,
too, the same reasoning applies: we don't want to worry that when we call a
macro it might use some name we've already used. In your case, this is your
exact intention, so racket allows you to break this protective mechanism
explicitly.

Deren

-- 
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] How to delay evaluation of a set! expression

2017-12-21 Thread Deren Dohoda
Hi Vityou,

Racket macros are procedures and like all procedures only have access to
values in their scope. Conceptually, yes, macros replace code with other
code, but how they do this is not like a glorified C preprocessor. One way
to manage this: you can move the definition of the procedure
"define/method" to a place where it knows what "method-list" is.

#lang racket
(require (for-syntax syntax/parse))

(define (make-person name age)
  (define-syntax (define/method stx)
  (syntax-parse stx
[(_ (name arg ...) body)
#'(begin (define (name arg ...) body)
 (set! method-list (cons `(name ,name) method-list)))]))
  (define method-list '())
  (define (obj arg)
(define/method (get-name) name)
(second (assq arg method-list)))
  obj)
;;;
Welcome to DrRacket, version 6.9 [3m].
Language: racket [custom]; memory limit: 8192 MB.
> (((make-person 'phil 12) 'get-name))
'phil

-- 
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] [ANN] MrEd Designer update

2017-09-30 Thread Deren Dohoda
Thanks, Laurent. MrEd is extremely handy.

Deren

-- 
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] new to racket‎

2017-08-05 Thread Deren Dohoda
Hello.

Racket is a language in which there are procedures and special forms
(syntax). When a procedure is called, arguments to it are evaluated, and
the result of that evaluation is then used in the procedure. Consider it
like this:

> (+ (* 2 3) (/ 2 3)) ; evaluate argument
; (+ 6 (/ 2 3)) ; evaluate argument
; (+ 6 2/3) ; apply +
20/3

"and" is a special form. It does not evaluate its arguments completely
before being applied. For instance, we don't want to divide by zero, so we
might write:

> (and (not (zero? denominator)) (/ numerator denominator))

If "and" were a normal procedure it would reduce like this in the case of a
0 denominator:
; (and #f (/ numerator denominator))
error: division by 0

But the whole point is to avoid division by zero. So "and" can't be a
procedure, it has to be syntax. Unfortunately this means it cannot be used
like procedures in compositions like map, foldr, etc. There are other forms
you can use:

> (andmap values '(#t #f))
or
> (for/and ((v '(#t #f)))
v)
#f

Deren


On Sun, Aug 6, 2017 at 12:12 AM,  wrote:

> new to racket‎.
>
> > (foldr + 0 '(1 2 3))
> 6
>
> but
>
> > (foldr and #t '(#t #f))
> and: bad syntax  and
>
> --
> 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.
>

-- 
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] Boot To Racket

2017-07-08 Thread Deren Dohoda
I actually use Racket in an embedded linux scenario on a 32-bit ARM. The
board has Debian installed but without twiddling boots under busybox. Once
upon a time I thought about giving a 5-minute presentation at Racketcon on
the experience of using Racket in this way but it never happened. It's very
hard to say what my hypothetical minimum requirements would be for such a
system without thinking of the hardware that would exist. Filesystem,
USB/RS232 serial/ whatever else the chip offers, and network seem like the
bare minimum. Are you thinking about some kind of minimal racket running on
a Raspberry Pi or something more abstract?

Deren

On Fri, Jul 7, 2017 at 8:16 PM, Lehi Toskin  wrote:

> I have this idea, this vision. I wish to create a small system that would
> more or less only be to turn on the machine (probably an RPi) and then
> you'd immediately be inside a Racket REPL. Probably wouldn't be very
> interesting by itself, but that seems to be almost exactly what eLua and
> MicroPython are.
>
> Say, for the sake of discussion, such a tiny system were created. What
> functionality would you expect to be available? Filesystem access?
> Networking? Or simply just the racket/base REPL and that's it?
>
> --
> 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.
>

-- 
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] hacking falsiness

2017-07-01 Thread Deren Dohoda
Matthew,

If your #lang has Greg's "if" then any module written in that #lang will
use that "if". So if I understand, your concern is that someone calls a
procedure which has some conditional behavior but that procedure, being
written in another module entirely, won't use Greg's "if". That is, your
#lang will provide all sorts of procedures from racket/base and other
modules, and those won't see Greg's "if". Is that correct?

On Sat, Jul 1, 2017 at 5:06 PM, Matthew Butterick  wrote:

> Good idea, but can I introduce a new macro (which naturally needs
> expansion) into a fully-expanded module (which does not)?
>
> IOW, it feels like you'd need to mangle #%kernel `if` before expansion, so
> that all the higher level expansions landed on the new mangled form.
>
> Mangling #%datum won't quite work, because it doesn't know whether the
> datum is being evaluated in a Boolean context.
>
> Feels like I'm wishing for a `#%boolean` hook that wraps a value that's
> about to be evaluated for its Boolean result.
>
> > On Jul 1, 2017, at 10:29 AM, Greg Hendershott 
> wrote:
> >
> > In fully-expanded programs, do all of the desired conditional forms
> > reduce to #%kernel `if`?
> >
> > If so, could your #%module-begin walk the fully-expanded module syntax
> > and replace all the #%kernel `if`s with something like (quick sketch):
> >
> > (require (rename-in racket/base [if r:if]))
> > (define-syntax-rule (if -e -t -f)
> >  (let ([e -e]
> >[f -f])
> >(r:if (eq? e #f)
> >  f
> >  (r:if (eq? e 0)
> >f
> >(r:if (eq? e null)
> >  f
> >  -t)
> >
> > ?
>
> --
> 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.
>

-- 
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] Re: Plot: line with histogram

2017-06-30 Thread Deren Dohoda
I asked too soon. It appears that the markers for histograms are not ticks.
So you can simply parameterize plot-x-ticks to no-ticks. This does not
affect the histogram markers.

Sorry for the noise.

Deren

On Fri, Jun 30, 2017 at 2:28 PM, Deren Dohoda <deren.doh...@gmail.com>
wrote:

> Hi Racketeers,
>
> I'm trying to put a horizontal line on a histogram plot so one can see
> whether the height passes some threshold. It's no problem for plot, but the
> ticks generated are some combination of how (function ...) wants to have
> ticks and how (discrete-histogram ...) wants to have ticks.
>
> Is there some way to suppress the ticks from the line, so only the
> discrete-histogram ticks are shown? Or for that matter to grab the ticks
> that discrete-histogram implies to parameterize the plot-x-ticks?
>
> Thanks,
> Deren
>

-- 
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] Plot: line with histogram

2017-06-30 Thread Deren Dohoda
Hi Racketeers,

I'm trying to put a horizontal line on a histogram plot so one can see
whether the height passes some threshold. It's no problem for plot, but the
ticks generated are some combination of how (function ...) wants to have
ticks and how (discrete-histogram ...) wants to have ticks.

Is there some way to suppress the ticks from the line, so only the
discrete-histogram ticks are shown? Or for that matter to grab the ticks
that discrete-histogram implies to parameterize the plot-x-ticks?

Thanks,
Deren

-- 
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: package naming (Was: [racket-users] Re: GLPK: how many chickens to invite to your picnic?)

2017-06-23 Thread Deren Dohoda
I already screwed up my uploaded package by using a plural and then later
read that the style guide suggests singulars. Embarrassing.

On Fri, Jun 23, 2017 at 5:57 PM, Neil Van Dyke  wrote:

> Jack Firth wrote on 06/23/2017 04:47 PM:
>
>> Pot-stirring question: do you think it would make more sense to name the
>> collection `math/glpk` instead of just `glpk`?
>>
>
> You're exactly right, it's a controversial question. :)
>
> In general, for a flexible, decentralized ecology of third-party packages,
> I think one usually wants either a flat namespace of package names, or
> (like PLaneT or Java) a namespace that's qualified by the package's
> origin.   (Qualified by one of the developer's identities, and whatever
> additional qualification the developer chooses to add.  In the case of
> Java, from the very start, they elegantly outsourced the namespace
> qualification authority to the Internet domain name registrations [*], but
> PlaneT's simple method was also reasonablee.)
>
> One mitigating factor, in this particular case, is that the author is a
> core Racket person, and there's an ancient legacy in core Racket, of
> sometimes using hierarchical package names for purely topical taxonomy
> purposes.  IMHO, this is suboptimal, but it's ancient precedent, so I
> wouldn't try debating it if core Racket continued to do this.
>
> Just know that, every time I gaze upon a new hierarchical package name
> used for purely topical taxonomy purposes, a single tear rolls down my
> somber face.
>
> [*] Java used the domain name registration system only to the extent that,
> if you owned a domain name, you were socially considered to have authority
> to name packages qualified with that name and subdomains.  They didn't use
> DNS itself at all, although you could imagine how DNS *could* later be used
> to implement package signature authentication in a distributed way, atop
> existing DNS infrastructure.  (Not that I'm advocating using DNS that way
> for Racket -- there some other ways of implementing authentication that
> make more pragmatic sense, given where we are.  And I'm not going to argue
> for Java-like use of domain registration authority in Racket, at least not
> unless it's part of implementing a trust system for packages.)
>
> --
> 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.
>

-- 
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] Expanding a macro into multiple syntax objects (Defining two things with one macro)

2017-06-22 Thread Deren Dohoda
Hi Sam,

​I'm a little unclear on your intended use case since (begin ...) does
splice defines, for instance:

(define (add-something x)
  (begin
(define one 1)
(define two 2))
  (+ x one two))
;;
Welcome to DrRacket, version 6.9 [3m].
Language: racket/base, with debugging; memory limit: 2048 MB.
> (add-something 5)
8

Can you be more clear on what's going wrong?

Deren​


On Thu, Jun 22, 2017 at 3:40 PM, Sam Waxman  wrote:

> Hello,
>
> It's simple enough to write a macro that defines something.
>
> (define-syntax-rule (my-define name binding)
>(define name binding))
>
> But what if I would like to define multiple things? I.e.
>
> (define-syntax-rule (my-multiple-define name ... binding ...)
>(define name binding) ...)
>
> The above is no good, because define-syntax-rule expects only one body to
> be returned, not multiple. Wrapping the defines in begin wouldn't work,
> because then they'd only be able to be accessed in the scope of that begin
> (when, in actuality, I want the rest of the code to access them, like they
> would be able to in the first example).
>
> Similarly, if I "upgrade" the syntax-rule to define-syntax, we run into
> the same problems. I thought that the following would work,
>
> (define-syntax (my-multiple-define stx)
>(syntax-case stx ()
>  [(_ name1 name2 binding1 binding2)
>#'(define name1 binding1)
>#'(define name2 binding2)]))
>
> but it looks like this only returns the last syntax object, not both of
> them.
>
> (Note, my actual goal here is to define something, then define a syntax
> rule afterwards like
>
> (define-syntax (my-multiple-define stx)
>(syntax-case stx ()
>  [(_ x y z)
>#'(define x y)
>#'(define-syntax-rule (z *stuff*)
>*some random body to the syntax-rule*)]))
>
> , so the solution of using define-values to do all the defines in one step
> won't work for me.)
>
> I'd be satisfied either with knowing how to make a macro expand into
> multiple syntax objects (so that one macro can expand into both defines),
> or with someone letting me know how to define something, then define a
> syntax rule afterwards using only one syntax object (like wrapping them in
> a begin but that bumps the definitions inside to the outer scope).
>
> Many thanks in advance!
>
> --
> 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.
>

-- 
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] Some inconsistent behavior with mutable prefab structs

2017-06-22 Thread Deren Dohoda
Thanks Matthew, that's fascinating. So do you think I was encountering it
due to something like background expansion and a test submodule with quoted
reference cases in my checks or something else? Maybe having that file open
while also working on a file that requires it? I looked over the source
file and don't see any kind of case like your example, but my test
submodule definitely includes such examples (the whole point of using
prefabs for me is the read behavior).

Deren

On Thu, Jun 22, 2017 at 12:22 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> This is a bug in prefab registration when an instance of the prefab is
> loaded via `read` before the `struct` declaration is encountered.
>
> In other words, putting
>
>  '#s((indexable (2 #f)) 0 #f)
>
> at the *start* of the first module below and running in a fresh Racket
> or DrRacket will demonstrate the problem. Running in a fresh Racket
> avoids any cached structure type for the prefab.
>
> The problem is specific to prefab struct types that include an auto
> field.
>
> I'll push a repair. Thanks for the report!
>
> At Thu, 22 Jun 2017 10:38:36 -0400, Deren Dohoda wrote:
> > Hi Racketeers,
> >
> > I am having some frustrations dealing with mutable prefab structures,
> > getting errors about attempting to mutate an immutable structure. I wish
> I
> > could give you a sequence of simple steps that I know for sure would
> > reproduce the problem but I have not found them. I thought I had one
> > yesterday, but then on a whim I blasted my racket installation and
> > reinstalled. This seemed to work. Today I go back to my files and my
> tests,
> > which have previously passed, are failing. This is extremely confusing
> > because in fact I have actually used this module already successfully
> > without any problems. I thought it was some module+ problem or rackunit
> > issue causing test failures but it is definitely not related to that as I
> > have it happen in other files entirely.
> >
> > Again I truly apologize for not having a more complete means of
> reproducing
> > the problem, but here is what I have right now. I am not even sure if you
> > follow my steps you can reproduce it.
> >
> > Launch DrRacket. Open the file "mutable-test.rkt", code below, failure
> for
> > no obvious reason:
> >
> > #lang racket/base
> > (struct indexable ((id #:auto)
> >(date #:auto))
> >   #:mutable
> >   #:prefab)
> >
> > (define indexed (indexable))
> > (set-indexable-id! indexed 0)
> > indexed
> >  ERROR
> > set-indexable-id!: cannot modify value of immutable field in structure
> >   structure: '#s((indexable (2 #f)) #f #f)
> >   field index: 0
> >
> > ;
> >
> > In file "mutable-test-2.rkt", success:
> >
> > #lang racket/base
> > (struct id ((index #:auto) (date #:auto)) #:mutable #:prefab)
> >
> > (for/list ((i (in-range 5)))
> >   (let ((I (id)))
> > (set-id-index! I i)
> > I))
> >
> > (struct derived id (val) #:prefab)
> >
> > (for/list ((i (in-range 5)))
> >   (let ((D (derived i)))
> > (set-id-index! D i)
> > D))
> >
> > Weird, right? Is the "indexable" name a problem? If I change the name by
> > just adding an "e" it works:
> >
> > #lang racket/base
> > (struct indexablee ((id #:auto)
> >(date #:auto))
> >   #:mutable
> >   #:prefab)
> >
> > (define indexed (indexablee))
> > (set-indexablee-id! indexed 0)
> > indexed
> > 
> >
> > Now I go back to "mutable-test.rkt" and simply change the structure
> > definition to remove the "date" field as so:
> > (struct indexable ((id #:auto))
> >   #:mutable
> >   #:prefab)
> >
> > and this also works.
> >
> > Any ideas?
> >
> > Thanks,
> > Deren
> >
> > --
> > 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.
>

-- 
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] Some inconsistent behavior with mutable prefab structs

2017-06-22 Thread Deren Dohoda
Hi Racketeers,

I am having some frustrations dealing with mutable prefab structures,
getting errors about attempting to mutate an immutable structure. I wish I
could give you a sequence of simple steps that I know for sure would
reproduce the problem but I have not found them. I thought I had one
yesterday, but then on a whim I blasted my racket installation and
reinstalled. This seemed to work. Today I go back to my files and my tests,
which have previously passed, are failing. This is extremely confusing
because in fact I have actually used this module already successfully
without any problems. I thought it was some module+ problem or rackunit
issue causing test failures but it is definitely not related to that as I
have it happen in other files entirely.

Again I truly apologize for not having a more complete means of reproducing
the problem, but here is what I have right now. I am not even sure if you
follow my steps you can reproduce it.

Launch DrRacket. Open the file "mutable-test.rkt", code below, failure for
no obvious reason:

#lang racket/base
(struct indexable ((id #:auto)
   (date #:auto))
  #:mutable
  #:prefab)

(define indexed (indexable))
(set-indexable-id! indexed 0)
indexed
 ERROR
set-indexable-id!: cannot modify value of immutable field in structure
  structure: '#s((indexable (2 #f)) #f #f)
  field index: 0

;

In file "mutable-test-2.rkt", success:

#lang racket/base
(struct id ((index #:auto) (date #:auto)) #:mutable #:prefab)

(for/list ((i (in-range 5)))
  (let ((I (id)))
(set-id-index! I i)
I))

(struct derived id (val) #:prefab)

(for/list ((i (in-range 5)))
  (let ((D (derived i)))
(set-id-index! D i)
D))

Weird, right? Is the "indexable" name a problem? If I change the name by
just adding an "e" it works:

#lang racket/base
(struct indexablee ((id #:auto)
   (date #:auto))
  #:mutable
  #:prefab)

(define indexed (indexablee))
(set-indexablee-id! indexed 0)
indexed


Now I go back to "mutable-test.rkt" and simply change the structure
definition to remove the "date" field as so:
(struct indexable ((id #:auto))
  #:mutable
  #:prefab)

and this also works.

Any ideas?

Thanks,
Deren

-- 
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] Code critique (of naive code) would be very appreciated

2017-06-21 Thread Deren Dohoda
Hi Glenn,

Because of the submodule system it's not necessarily a good idea to put
running code in the file directly. If you want something to run when the
file is the main file (e.g. run in drracket) you can use (module* main #f
...). This way (module+ test ...) doesn't execute these things, and if the
file is required for any items it provides that code isn't run, either.

Consider this example:
#lang racket/base

(define (add2 x)
  (and (number? x)
   (+ 2 x)))
(displayln "in file")

(module* main #f
  (displayln "in main")
  (add2 3))

(module+ test
  (require rackunit)
  (displayln "in test")
  (check-= (add2 3) 5 0)
  (check-false (add2 'q)))
;
Welcome to DrRacket, version 6.9 [3m].
Language: racket/base, with debugging; memory limit: 128 MB.
in file
in test
in main
5
>

Two things to notice: 1) "test" is run before "main"; 2) all the code from
"in file" is run before any "test" or "main". If you're counting on your
tests to tell you whether it's ok to run the code then I hope you see my
point from the first paragraph that such code should be moved to a
different module or the "main" submodule.

Deren

On Wed, Jun 21, 2017 at 3:48 PM, Glenn Hoetker  wrote:

> With help from this group, I've written my first baby-program in Racket
> and would really appreciate any feedback on how to make it more idiomatic,
> efficient and well-formatted (I struggle with where to break lines). Thank
> you in advance.
>
> The purpose is to fix the irregular capitalization of entries in the
> "Keywords" field of a large BibLaTeX (.bib) file. A sample entry in the
> input file might be
>
> @article{Ender-2016-Review-00,
> Author = {Ender, P. B.},
> Keywords = {Book Review, Behaviorial sciences, ANALYSIS OF
> VARIANCE, experimental design},
> ...}
>
> I want non-Keyword lines passed unchanged to the output file and each
> keyword entry (potentially multiword) changed to have only its first word
> capitalized. Thus
>
> @article{Ender-2016-Review-00,
> Author = {Ender, P. B.},
> Keywords = {Book review, Behaviorial sciences, Analysis of
> variance, Experimental design},
> ...}
>
>
> Here is what I came up with.
>
> ;;;
> #lang racket
>
> (define in (open-input-file "/Users/me/BibDeskPapers/oldBib.bib"))
> (define out (open-output-file "/Users/me/BibDeskPapers/newBib.bib"
> #:exists 'replace))
> (define keyword-prefix "\tKeywords = {")
>
> ;; Return a string with only the first word capitalized and all else in
> lower case
> ;; Courtesy https://groups.google.com/forum/m/#!topic/racket-users/
> gw8Ivm5HSZQ
> (provide
>  (contract-out
>   [string-upcase-first-word (-> string? string?)]))
>
> (define (string-upcase-first-word s)
>   (apply
>string
>(for/list ([c (in-string s)]
>   [i (in-naturals)])
>  (if (= i 0)
>  (char-upcase c)
>  (char-downcase c)
>
> (module+ test
>   (require rackunit)
>   (check-equal? (string-upcase-first-word "") "")
>   (check-equal? (string-upcase-first-word "Cat Dog") "Cat dog")
>   (check-equal? (string-upcase-first-word "cat dog") "Cat dog"))
>
> ;; Main program
> (for ([aLine (in-lines in)])
>   (cond
> [(string-prefix? aLine "\tKeywords = {") ; Identify Keywords lines
>  (define keywords-as-list (string-split (string-replace aLine
> "\tKeywords = {" "") ","))
>  (define cleaned-keywords (map (lambda (aString)
>  (string-upcase-first-word
>   (string-trim aString)))
>keywords-as-list))
>  (display keyword-prefix out)
>  (display (string-join cleaned-keywords ", ") out)
>  (display "," out)
>  (newline out)]
> [else (display aLine out) (newline out)]))
>
> ;;;
>
> Thank you again.
>
> --
> 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.
>

-- 
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] RacketCon Code of Conduct

2017-06-19 Thread Deren Dohoda
If by whiskey, Jack. Your guarantees on this matter are unenforceable and
therefore meaningless, and any further comment on my ignorance will likely
violate any CoC you care to throw your weight behind, so best get it out
now because you can't unring this bell.

On Mon, Jun 19, 2017 at 8:08 PM, Jack Firth  wrote:

> > These are invariably motte and bailey style arguments and the notion
> that the only reason I or anyone else could possibly resent CoCs is some
> desire to abuse their absence is astonishing. How you could not find such
> groupthink "censorious" is beyond my ability to sympathize with. I can only
> reiterate that CoCs are not some kind of dealbreaker for me personally but
> as this is an open discussion I will just say I don't think they're all
> benefit and no cost. My disagreement on this matter does not constitute an
> admission of guilt; to abuse a racket construct: there's a bug in your
> contract spec, it's blaming the wrong party.
>
> The important point is that a CoC is a choice to prioritize the safety,
> welfare, and happiness of minority groups over the privilege of individuals
> to say / do whatever they want. Sure, you might say that's a tradeoff, and
> sure, you could call that censorship, but whatever "cost" there is of
> hypothetically blaming a party inappropriately is worth paying ten times
> over for the benefit of making traditionally less-welcomed people more
> included. I guarantee you the incidents a CoC is designed to prevent occur
> *far* more often than any incidents of mis-applying the CoC to an innocent
> individual. Not realizing that is willful ignorance.
>
> --
> 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.
>

-- 
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] RacketCon Code of Conduct

2017-06-19 Thread Deren Dohoda
>Bluntly, if someone finds the admonition to refrain from harassment
"censorious", then it is likely they are exactly the sort of person that a
Code of Conduct is in fact *designed* to make feel unwelcome.

These are invariably motte and bailey style arguments and the notion that
the only reason I or anyone else could possibly resent CoCs is some desire
to abuse their absence is astonishing. How you could not find such
groupthink "censorious" is beyond my ability to sympathize with. I can only
reiterate that CoCs are not some kind of dealbreaker for me personally but
as this is an open discussion I will just say I don't think they're all
benefit and no cost. My disagreement on this matter does not constitute an
admission of guilt; to abuse a racket construct: there's a bug in your
contract spec, it's blaming the wrong party.

On Mon, Jun 19, 2017 at 3:31 PM, John Berry  wrote:

> The problem with the longer text, such as the Strange Loop one[1], is that
>> it's manifestly _very_ hard to come up with a text that doesn't radiate
>> censoriousness; and however much this isn't the literal implication of the
>> text, it does implant the notion that the reader or the community has
>> behaviour problems.  That text does not radiate 'you are welcome' -- it
>> tells me, 'we have so many gits roaming the corridors of our conference
>> that we have to police them'.  In its phrasing, a text like this appears to
>> presume that the reader is an undersocialised thug, who needs to be given
>> an extensive but non-exhaustive list of things to remember not to do.  One
>> has to carefully suppress one's initial reaction to it, and smile sweetly.
>
>
> Bluntly, if someone finds the admonition to refrain from harassment
> "censorious", then it is likely they are exactly the sort of person that a
> Code of Conduct is in fact *designed* to make feel unwelcome.
>
> This is a feature, not a design flaw.
>
>
>
> On Mon, Jun 19, 2017 at 9:13 PM, Stephen De Gabrielle <
> spdegabrie...@gmail.com> wrote:
>
>> I would suggest that it is more important to get a COC on the RacketCon
>> website than it is to argue over the wording. I would suggest that every
>> day that passes without a CoC on the website adds to the risk that possible
>> racketcon participants might decide not to go... to the detriment of the
>> Racket community.
>>
>> I really love how welcoming this community is - even more than I love the
>> ideas you put into or expressed with Racket. It is your greatest strength.
>>
>> Kind regards
>>
>> Stephen
>> On Mon, 19 Jun 2017 at 18:55, Norman Gray  wrote:
>>
>>>
>>> Greetings.
>>>
>>> On 19 Jun 2017, at 16:18, John Berry wrote:
>>>
>>> > Nothing about a document saying "hey, don't be an ass" implies that
>>> > the
>>> > reader themselves, or the community, are asses. Only that the
>>> > community
>>> > values not being an ass, and those who might wish to join that
>>> > community
>>> > and not be an ass are welcome, and that those who have had to deal
>>> > with too
>>> > many asses will hopefully find fewer here.
>>>
>>> If the document literally said just 'hey, don't be an ass', or 'don't be
>>> a git', or 'c'mon, behave', then that would be fine.  Perhaps it could
>>> have a footnote saying 'Surely you can tell when you're being a git --
>>> if you for some reason have difficulty with this, then see [link]'.  A
>>> text like that presumes that the reader is grown-up, but indicates, for
>>> the avoidance of doubt, that adult civility is indeed expected in the
>>> meeting.
>>>
>>> The problem with the longer text, such as the Strange Loop one[1], is
>>> that it's manifestly _very_ hard to come up with a text that doesn't
>>> radiate censoriousness; and however much this isn't the literal
>>> implication of the text, it does implant the notion that the reader or
>>> the community has behaviour problems.  That text does not radiate 'you
>>> are welcome' -- it tells me, 'we have so many gits roaming the corridors
>>> of our conference that we have to police them'.  In its phrasing, a text
>>> like this appears to presume that the reader is an undersocialised thug,
>>> who needs to be given an extensive but non-exhaustive list of things to
>>> remember not to do.  One has to carefully suppress one's initial
>>> reaction to it, and smile sweetly.
>>>
>>> Also, any text like that almost inevitably acquires a legalistic air,
>>> and just screams out for disputation, and the reddit thread...
>>>
>>> > For the unconvinced, I really appreciated Graydon Hoare's perspective
>>> > on
>>> > why he implemented the Rust CoC.
>>> > https://www.reddit.com/r/rust/comments/6ewjt5/question_
>>> > about_rusts_odd_code_of_conduct/didrult/
>>> > https://www.reddit.com/r/rust/comments/6ewjt5/question_
>>> > about_rusts_odd_code_of_conduct/dif1xvb/
>>>
>>> ...seems to corroborate this.
>>>
>>> To clarify, this remark is about communication and presentation.  The
>>> underlying wish to encourage civility 

Re: [racket-users] RacketCon Code of Conduct

2017-06-17 Thread Deren Dohoda
I don't believe virtue signaling can ever substitute for actual virtue. If,
however, a failure to signal virtue is interpreted as a vice, then this is
a sticky situation indeed. There is the argument that if everyone behaved
we wouldn't need laws, but there is also the argument that people still
misbehave even with laws. I do not have shoulders high enough to stand on
to get a clear view of this topic (I'm quite sure such heights have never
been reached). What I do know is that I resent CoCs as much as I resent
software agreements which I must acquiesce to in order to use something. I
don't believe they are a good idea. But in the end I always click "agree"
and install the software anyway.

On Sat, Jun 17, 2017 at 5:46 PM, Neil Van Dyke  wrote:

> Unfortunately, event "codes of conduct" started, in part, as reactions to
> actual bad behavior at some (non-Racket) events.
>
> I agree that RacketCon doesn't need a code of conduct to tell people how
> to behave.  But people relatively new to Racket might not know that.
> Hence, the conventional "code of conduct", or maybe simply a statement that
> affirms that everyone is welcome.
>
> For all I know, the following might suffice as a welcoming statement. :)
>
> Matthias Felleisen wrote on 06/17/2017 02:50 PM:
>
>> Racketeers were raised properly by their parents and are well behaved.
>>
>
> --
> 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.
>

-- 
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] Standalone Executables and shared libraries

2017-02-24 Thread Deren Dohoda
Hi racketeers,

I must be doing something wrong. I apologize for a very long explanation of
incongruities I find. What is the intended method of using shared libraries
in Racket so that
--- DrRacket works when the file is opened
--- DrRacket works when the file is opened from the recently used file list
--- DrRacket works when the file is opened through OS file associations
--- The executable works when created through DrRacket
--- The executable works when created through raco exe + raco distribute

I have a set of shared libraries from a vendor I cannot mess with. I load
one, it loads others. There is a directory for accessing these I'll call
"vendor-dir". In vendor-dir is a racket file I'll call "interface.rkt"
that, using the FFI, loads these libraries and provides an interface for
the purpose of my application. This is good when working with this racket
file.

However, in the main project directory is "main.rkt" which requires
"vendor-dir/interface.rkt". When I open "main.rkt" I have to have the
libraries relative to main.rkt, so I copy all of them out of "vendor-dir"
into my project directory.

This all only works when I launch DrRacket with no files, then open
"main.rkt". If I use the recently used file list, the library can't be
found in either of those locations. Also when opening via OS file
associations.

When I create the executable from DrRacket's menu item, the library can't
be found. OK, I alter the source to print out where it is looking for
libraries and put the DLLs there, but no dice. I have included these files
in the dialog box but no dice. OK, so forget "create executable."

I can only get the executable to work when I use raco exe, then raco
distribute, then move the DLLs to the top level where the executable is put.

I am guessing something like "define-runtime-path" is needed here and I
won't bore you with the various things I've tried, but ultimately I can
only succeed with the two methods described above. What am I supposed to be
doing differently?

Thanks,
Deren

-- 
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] Package layout in docs

2017-01-29 Thread Deren Dohoda
Honestly I've never even thought about this. I just look at the "require"
form at the top of the docs. Since I always use racket/base as my main
language, everything feels like extra.

On Sun, Jan 29, 2017 at 8:45 AM, Matthew Flatt  wrote:

> At Sat, 28 Jan 2017 22:51:43 -0800 (PST), Ethan Estrada wrote:
> > My only real beef with the Racket docs are the layout of packages;
> > there is no clear distinction between docs for standard library items
> > and docs for community provided libs.
>
> That's intentional. I'd say that the absence of a line that
> distinguishes "Racket" from "not Racket" at the package level is an
> extrapolation of our goal to avoid a line between the "language" and
> "library" at the level of a module.
>
> There are certainly some drawbacks to allowing any old module to add
> new constructs to the programming language, but we think the benefits
> outweigh the drawbacks. Similarly, there are some drawbacks to allowing
> any old package to have the same status as the base system, but I
> believe in the benefits.
>
> In both cases, it's important that programmers have control over what
> is used and what isn't used. The module system enforces boundaries so
> that a module added to a program can't have an arbitrary effect on
> other modules in the program. Similarly, the package system is intended
> to give the programmer control over what packages are installed and how
> they are installed.
>
> I'm not objecting to improvement here --- just trying to clarify why
> the current organization is like that.
>
> Also, I'd concede that we have a notion of "main distribution", which
> identifies a set of packages that are included in the Racket installers
> at racket-lang.org. That's a useful concept, but I see it as a
> compromise, and I'm reluctant to reflect that distinction in the
> documentation.
>
> --
> 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.
>

-- 
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] Package Providing results from another package

2017-01-26 Thread Deren Dohoda
I have a collection based on polynomial code I wrote which I intend to
release at some time in the near future for some simple data processing
routines. The somewhat optimized underlying data structure for random
access use of one of my procedures would be a tree, but the somewhat
optimized structure for plotting would not be a tree but a simple list of
renderers from the plot package. So I intend to offer a separate procedure
for plotting purposes.

In general, this package would only require racket/base, but this one
particular procedure would require plot. What is the right way to handle
this? Should I only include plot in this particular module and expect the
user to also require plot, or include plot and re-provide all-from-out?
Should it be a separate module for just this procedure to avoid unnecessary
loading of the plot library if it isn't used?

Example collection:
simple-polynomial/base
simple-polynomial/spline (may require plot for one procedure)
etc..

Thanks,
Deren

-- 
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] String to list?

2017-01-12 Thread Deren Dohoda
In general you can (read (open-input-string " ...")).

In this case
(second (read (open-input-string "'(2 2 2)")))
Since read will quote the input and if you don't take the second element
you'll get
''(2 2 2)

Deren

On Fri, Jan 13, 2017 at 2:18 AM, Andreas Olsson 
wrote:

> If i got " '(2 2 2) " as input via read-line and want to convert it to '(2
> 2 2), how do I do it?
>
> --
> 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.
>

-- 
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] [ANN] New packages: compose-app and retry

2017-01-11 Thread Deren Dohoda
Thanks a lot! Retryers are fantastic. I have poorly written this code more
than a few times and I like the model a lot.

Deren

On Tue, Jan 10, 2017 at 10:31 PM, Jack Firth  wrote:

> I've added two new packages to the package catalog. The first,
> `compose-app`, provides a
> simple #%app macro for composing single-argument functions together:
>
> > (require compose-app)
> > (map (add1 .. string->number) (list "1" "2" "3"))
> (list 2 3 4)
>
> Optionally, you can use the package with `fancy-app` to get both
> composition syntax and underscores-as-lambdas syntax:
>
> > (require compose-app/fancy-app)
> > (map (/ _ 2 .. string->number) (list "10" "20" "30"))
> (list 5 10 15)
>
> The second package, `retry`, provides "retryers" for repeating operations
> in the event of failure. To use, first construct retryers for each action
> you wish to do (e.g. sleep X seconds, log a message, etc.), then combine
> the retryers together with `retryer-compose`, then use `call/retry` or
> `with-retry` to evaluate something until it succeeds.
>
> For more information, see:
>
> - The `compose-app` docs: http://docs.racket-lang.org/
> compose-app/index.html
> - The `retry` docs, including The Retry Guide and The Retry Reference:
> http://docs.racket-lang.org/retry/index.html
> - The `compose-app` Github repo: https://github.com/jackfirth/compose-app
> - The `retry` Github repo: https://github.com/jackfirth/racket-retry
> - The `fancy-app` Github repo: https://github.com/samth/
> fancy-app/tree/master
>
> Patches, issues, comments, musings, and lollipops are all welcome. Special
> thanks to Sam for fancy-app!
>
> --
> 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.
>

-- 
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] literals vs datum-literals in syntax-parse

2017-01-10 Thread Deren Dohoda
I am still making most macros using syntax-rules and syntax-case because
when I happened to learn macros these were the paths of least resistance.
Every once in a while I try to learn a little more of syntax-parse since
the few times I've tried it I really liked it.

It appears that, in general, syntax-rules and syntax-case use what
syntax-parse considers "datum-literals", which the docs say are recognized
"symbolically" versus actual literals which are recognized "by binding."
The example in the documents for some reason clarifies nothing since both
expressions are the same and give the same output, making this a
distinction without an obvious difference.

Can someone explain the intention behind #:literals as opposed to
#:datum-literals? In what cases should I consider #:literals? Why would I
want to avoid #:datum-literals, or vice versa?

Thanks,
Deren

-- 
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] racket 6.7 minimal+prebuilt no raco make?

2017-01-10 Thread Deren Dohoda
Thanks, Sam. Got it.

On Tue, Jan 10, 2017 at 10:23 AM, Sam Tobin-Hochstadt <sa...@cs.indiana.edu>
wrote:

> The `compiler-lib` pkg will install the `raco make` command.
>
> Sam
>
> On Tue, Jan 10, 2017 at 10:21 AM, Deren Dohoda <deren.doh...@gmail.com>
> wrote:
> > Basically the subject.
> >
> > Downloaded the source for 6.7 minimal with prebuilt packages, compiled. I
> > didn't see any errors. But apparently there's no "make" command for raco?
> > The docs don't indicate this disappeared so I am a little confused. raco
> > help indicates make is not a recognized command:
> >
> > -
> > root@foo:~# racket/racket-6.7/bin/raco help
> > Usage: raco   ...  ...
> >
> > Frequently used commands:
> >   setup   install and build libraries and documentation
> >   pkg manage packages
> >
> > All available commands:
> >   linkmanage library-collection directories
> >   pkg manage packages
> >   setup   install and build libraries and documentation
> >
> > A command can be specified by an unambiguous prefix.
> > See `raco help ' for help on a command.
> > -
> >
> > Did the install mess up? Is make some separate package I need to install
> > since this is "minimal"?
> >
> > Deren
> >
> > --
> > 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.
>
> --
> 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.
>

-- 
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] racket 6.7 minimal+prebuilt no raco make?

2017-01-10 Thread Deren Dohoda
Basically the subject.

Downloaded the source for 6.7 minimal with prebuilt packages, compiled. I
didn't see any errors. But apparently there's no "make" command for raco?
The docs don't indicate this disappeared so I am a little confused. raco
help indicates make is not a recognized command:

-
root@foo:~# racket/racket-6.7/bin/raco help
Usage: raco   ...  ...

Frequently used commands:
  setup   install and build libraries and documentation
  pkg manage packages

All available commands:
  linkmanage library-collection directories
  pkg manage packages
  setup   install and build libraries and documentation

A command can be specified by an unambiguous prefix.
See `raco help ' for help on a command.
-

Did the install mess up? Is make some separate package I need to install
since this is "minimal"?

Deren

-- 
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] Narrow radix of string->number.

2017-01-04 Thread Deren Dohoda
Yes, Robby, if the new base fits within the range allowed by number->string.

On Wed, Jan 4, 2017 at 1:49 PM, Robby Findler <ro...@eecs.northwestern.edu>
wrote:

> Is changing the alphabet something that can be done post-facto with
> string replacements?
>
> Robby
>
>
> On Wed, Jan 4, 2017 at 12:46 PM, Deren Dohoda <deren.doh...@gmail.com>
> wrote:
> > Some food for thought on this topic, I use base conversion for all sorts
> of
> > silly things. To this end I require a great deal of flexibility in
> > representation. When I wrote my continued-fractions package I included
> this
> > as a separate module. Here's an example:
> >
> > Welcome to DrRacket, version 6.7 [3m].
> > Language: racket/base, with debugging [custom]; memory limit: 2048 MB.
> >> (require continued-fractions/bases)
> >
> > (define rep (make-representation #:radix #\!
> >  #:negate #\+
> >  #:terms
> > "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"))
> >
> > (parameterize ((representation rep)
> >(digits 10))
> >   (let ((n (/ -125382661425156036913657 101559956668416)))
> > (let ((s (->string n)))
> >   (displayln s)
> >   (let ((n* (->number s)))
> > (= n n*)
> > +KF12OI!4FZZZXRSP
> > #t
> >>
> >
> > This may be pointlessly more flexible than a normal user of
> number->string
> > would want but an arbitrary alphabet is something I'd request people
> > consider for a few moments if changing number->string is open for debate.
> > Maybe it is too much flexibility for racket/base, though, which is where
> > number->string lives.
> >
> > Deren
> >
> > On Wed, Jan 4, 2017 at 11:38 AM, Gustavo Massaccesi <gust...@oma.org.ar>
> > wrote:
> >>
> >> I'm still worried about bignums. So I borrowed the idea of Mathew of
> >> splitting the number in 1/2/3 digits chucks, but I use fixnum chunks.
> >> For each fixnum chunk I calculate the string representation as usual,
> >> but as most of the calculations involve only fixnum, then It's x4
> >> faster for bignums.
> >>
> >> It's slightly slower for the DrRacket distribution and fixnums and
> >> (5%-10%).
> >>
> >> The code assumes that a 9 is a fixnum, this is true for 32 and
> >> 64 bit's racket. (In case Racket is ported in the future to a 16 bits
> >> platform, the code is still correct but slower.)
> >>
> >> DrRacket distribution of numbers
> >> number->string cpu time: 4907 real time: 4898 gc time: 77
> >> number->string* cpu time: 3703 real time: 3701 gc time: 0
> >> number->string** cpu time: 6782 real time: 6777 gc time: 16
> >> number->string*** cpu time: 3797 real time: 3796 gc time: 16
> >>
> >> Always N=123 (10 times less calls)
> >> number->string cpu time: 859 real time: 846 gc time: 0
> >> number->string* cpu time: 1688 real time: 1676 gc time: 31
> >> number->string** cpu time: 672 real time: 673 gc time: 0
> >> number->string*** cpu time: 1796 real time: 1800 gc time: 0
> >>
> >> Always N=1234567890123456789012345678901234567890 (10 times less calls)
> >> number->string cpu time: 5625 real time: 5623 gc time: 0
> >> number->string* cpu time: 102125 real time: 102100 gc time: 403
> >> number->string** cpu time: 750 real time: 748 gc time: 15
> >> number->string*** cpu time: 26343 real time: 26337 gc time: 95
> >>
> >> Gustavo
> >>
> >> ;Here is ony the code of the new function and benchmarks
> >> ;I'm not happy with the names of the auxiliary functions.
> >>
> >> (define (number->string***/fixed N short-size trim)
> >>   (define str (make-string short-size #\0))
> >>   (let loop ([N N] [i short-size])
> >> (cond
> >>   [(zero? N)
> >>(if trim
> >>(substring str i short-size)
> >>str)]
> >>   [else
> >>(define q (quotient N 10))
> >>(define r (remainder N 10))
> >>(define d (integer->char (+ r (char->integer #\0
> >>(string-set! str (- i 1) d)
> >>(loop q (- i 1))])))
> >>
> >> (define (number->string***/bignum/list N tail)
> >>   (define-values (q r) (quotient/remainder N (expt 10 9)))
> >>   (cond
> >> [(zero? q)
> >>  (cons (number->string***/fixe

Re: [racket-users] Narrow radix of string->number.

2017-01-04 Thread Deren Dohoda
Some food for thought on this topic, I use base conversion for all sorts of
silly things. To this end I require a great deal of flexibility in
representation. When I wrote my continued-fractions package I included this
as a separate module. Here's an example:

Welcome to DrRacket, version 6.7 [3m].
Language: racket/base, with debugging [custom]; memory limit: 2048 MB.
> (require continued-fractions/bases)

(define rep (make-representation #:radix #\!
 #:negate #\+
 #:terms
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"))

(parameterize ((representation rep)
   (digits 10))
  (let ((n (/ -125382661425156036913657 101559956668416)))
(let ((s (->string n)))
  (displayln s)
  (let ((n* (->number s)))
(= n n*)
+KF12OI!4FZZZXRSP
#t
>

This may be pointlessly more flexible than a normal user of number->string
would want but an arbitrary alphabet is something I'd request people
consider for a few moments if changing number->string is open for debate.
Maybe it is too much flexibility for racket/base, though, which is where
number->string lives.

Deren

On Wed, Jan 4, 2017 at 11:38 AM, Gustavo Massaccesi 
wrote:

> I'm still worried about bignums. So I borrowed the idea of Mathew of
> splitting the number in 1/2/3 digits chucks, but I use fixnum chunks.
> For each fixnum chunk I calculate the string representation as usual,
> but as most of the calculations involve only fixnum, then It's x4
> faster for bignums.
>
> It's slightly slower for the DrRacket distribution and fixnums and
> (5%-10%).
>
> The code assumes that a 9 is a fixnum, this is true for 32 and
> 64 bit's racket. (In case Racket is ported in the future to a 16 bits
> platform, the code is still correct but slower.)
>
> DrRacket distribution of numbers
> number->string cpu time: 4907 real time: 4898 gc time: 77
> number->string* cpu time: 3703 real time: 3701 gc time: 0
> number->string** cpu time: 6782 real time: 6777 gc time: 16
> number->string*** cpu time: 3797 real time: 3796 gc time: 16
>
> Always N=123 (10 times less calls)
> number->string cpu time: 859 real time: 846 gc time: 0
> number->string* cpu time: 1688 real time: 1676 gc time: 31
> number->string** cpu time: 672 real time: 673 gc time: 0
> number->string*** cpu time: 1796 real time: 1800 gc time: 0
>
> Always N=1234567890123456789012345678901234567890 (10 times less calls)
> number->string cpu time: 5625 real time: 5623 gc time: 0
> number->string* cpu time: 102125 real time: 102100 gc time: 403
> number->string** cpu time: 750 real time: 748 gc time: 15
> number->string*** cpu time: 26343 real time: 26337 gc time: 95
>
> Gustavo
>
> ;Here is ony the code of the new function and benchmarks
> ;I'm not happy with the names of the auxiliary functions.
>
> (define (number->string***/fixed N short-size trim)
>   (define str (make-string short-size #\0))
>   (let loop ([N N] [i short-size])
> (cond
>   [(zero? N)
>(if trim
>(substring str i short-size)
>str)]
>   [else
>(define q (quotient N 10))
>(define r (remainder N 10))
>(define d (integer->char (+ r (char->integer #\0
>(string-set! str (- i 1) d)
>(loop q (- i 1))])))
>
> (define (number->string***/bignum/list N tail)
>   (define-values (q r) (quotient/remainder N (expt 10 9)))
>   (cond
> [(zero? q)
>  (cons (number->string***/fixed r 9 #t) tail)]
> [else
>  (number->string***/bignum/list q (cons (number->string***/fixed r
> 9 #f) tail))]))
>
> (define (number->string*** N)
>   (cond
> [(fixnum? N)
>  (cond
>[(< N 10)
> (string (integer->char (+ (char->integer #\0) N)))]
>[(< N (expt 10 9))
> (number->string***/fixed N 9 #t)]
>[else
> (apply string-append (number->string***/bignum/list N '()))])]
> [else
>  (apply string-append (number->string***/bignum/list N '()))]))
>
> ;(define-syntax-rule (test-it id ...) ...)
>
> (define iterations 5)
>
> (define-syntax-rule (time-it id ...)
>   (begin
> (define numbers (for/list ([i (in-range 1000)])
>   (sample/drr)))
> (begin
>   (collect-garbage)
>   (time
>(for* ([x (in-range iterations)]
>   [n (in-list numbers)])
>  (id n))
>(printf "~a " 'id))) ...))
>
> (time-it number->string number->string* number->string** number->string***)
>
> (define-syntax-rule (time-it-N N id ...)
>   (begin
> (begin
>   (collect-garbage)
>   (time
>(for* ([x (in-range (* 100 iterations))])
>  (id N))
>(printf "~a " 'id))) ...))
>
> (time-it-N 123 number->string number->string* number->string**
> number->string***)
> (time-it-N 1234567890123456789012345678901234567890 number->string
> number->string* number->string** number->string***)
> ;---
>
>
> On Sun, Jan 1, 2017 at 8:01 PM, Robby Findler
> 

Re: [racket-users] Newbie seeking advice

2016-12-20 Thread Deren Dohoda
I learned programming for fun. I still enjoy it today, but I don't think I
would have stuck with it without aspirations of endless tinkering. It is
that aspect I seem to enjoy the most.

Counterfactual scenarios are too easy to wax philosophical about. I didn't
start with any lisp, but I wish I had. Whether I enjoy Racket so much
because I started with something else or because it is just that good is
something only those wiser than me can say. I think the latter, but I can't
relive my life to test the hypothesis.

Deren

On Dec 20, 2016 3:18 PM, "Matthias Felleisen"  wrote:

>
> > On Dec 20, 2016, at 2:12 PM, 'John Clements' via Racket Users <
> racket-users@googlegroups.com> wrote:
> >
> > Learning to program takes a long time, and is best done with friends.
> The decision of how to learn, and in what context, is probably more
> important than your choice of language or even your choice of curriculum.
>
> Ouch.
>
> --
> 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.
>

-- 
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] Custodian/Will question

2016-04-21 Thread Deren Dohoda
Thanks,  Matthew.  There's safety and then there's safety. I'm mostly
concerned with and application-level soft reset. I can add some thread
messaging to make sure the thread dies on its own, then shut down
everything. I was hoping to avoid this plumbing.

Deren
On Apr 21, 2016 10:40 AM, "Matthew Flatt" <mfl...@cs.utah.edu> wrote:

> At Tue, 19 Apr 2016 10:39:57 -0400, Deren Dohoda wrote:
> > I have a thread that can only be shut down during certain points:
>
> In general, you can't implement that safety in Racket, in much the same
> way you can't implement that in Unix or Windows process.
>
> As long as the thread might get shut down through
> `custodian-shutdown-all` (like a Unix process might get terminated with
> SIGKILL), there's nothing the thread can do about it --- at least not
> safely.
>
> There's also no way to register arbitrary code to run in the event that
> a thread gets killed (in the same way that there's no API for
> registering code to run if your process is killed in Unix). If there
> were such a feature, then a thread could just put all of its work in
> that callback, and there would be no way to reliably terminate a
> thread's computation.
>
>
> > [...] it does
> > some writing operations on a port and this write must finish under normal
> > circumstances. I worry that if this thread is managed by a custodian and
> > custodian-shutdown-all is called that the thread may die in the middle
> of a
> > write operation on a port. Is this where I would use a will?
>
> Wills are unlikely to help. It depends on your situation, but in a
> typical case where a thread might get shut down through a custodian, a
> thread that's acting as a will executor can also get shut down.
>
> There is an unsafe function, `register-finalizer`, which lets you
> register a will that has an executor thread that can never get killed
> (unless the whole Racket process is killed). That's probably not what
> you want, but I mention it for completeness.
>
>
> Using a particular pattern, you can use to make something "kill safe"
> in the following sense: if multiple clients are using an object, and if
> one of them is killed while manipulating the object, a later use by a
> different client can pick up where the previous thread left off to
> restore the object to usability. See the paper "Kill-Safe
> Synchronization Abstractions" for more on that pattern.
>
> Along those lines, if there's some thread X that won't get killed
> relative to another set of threads, you can have X run the action or
> have it start a new thread with X's custodian to ensure that the action
> will complete. At least, it will complete relative to the threads that
> might get killed. Whether you can arrange for such an X depends on how
> much your program is in control from the start.
>
>
> If you have something where you need an action to complete atomically
> --- even if no future client touches the relevant object and you don't
> have access to a thread that will definitely continue --- then it's not
> possible to implement that safely. In the grand scheme of things, it's
> not possible to implement at all, at least for an arbitrary action; the
> Racket process might get killed, the power might go out, and so on.
>
> If termination external to Racket run-time system is not a concern,
> then you can implement atomic actions unsafely. See
> `ffi/unsafe/atomic`. Please be aware that atomicity really is unsafe;
> you need to know the full affect of any function called in atomic mode
> to make sure that it cannot lead to deadlock or similar problems.
> Generally, that's how actions like shutting down a custodian can be
> implemented atomically relative to the rest of the Racket runtime
> system; those primitives are implemented (carefully!) to run in atomic
> mode.
>
>

-- 
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] Custodian/Will question

2016-04-19 Thread Deren Dohoda
Hi Racketeers,

I'm a little unclear on the right way to use custodians and wills.

I have a thread that can only be shut down during certain points: it does
some writing operations on a port and this write must finish under normal
circumstances. I worry that if this thread is managed by a custodian and
custodian-shutdown-all is called that the thread may die in the middle of a
write operation on a port. Is this where I would use a will? I don't quite
understand how this behavior is intended to be supported.

Thanks for any advice,
Deren

-- 
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] racket users fight for their right to colon keywords

2015-10-15 Thread Deren Dohoda
I don't have a very strong opinion, it seems like convenient syntax, but
half of what draws me to stick with lisps is the low amount of syntax.
Pound-colon has a strong line noise quality to it which colons lack,  I
admit. But they also have an explicit feel which colons lack.

Inclusion or exclusion of this will not really affect me though. I will
probably stick to pound-colon.

Deren

-- 
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] Formatting Function

2015-10-12 Thread Deren Dohoda
Hi Taro,

Probably racket/format is what you need to look at.
http://docs.racket-lang.org/reference/strings.html#%28mod-path._racket%2Fformat%29

#lang racket/base
(require racket/format)
(define (this-format num)
  (~a #:min-width 3 #:align 'right #:pad-string "0"
  num))
(this-format 5) ;=> "005"

Regards,
Deren


On Mon, Oct 12, 2015 at 12:16 PM, Taro Annual 
wrote:

> Hi,
>
> Please tell me the way of the following in racket?
>
> In C,
> printf("%02d", 2);
>
> In Common Lisp,
> (format t "~2,'0D" 2)
>
> --
> 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.
>

-- 
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] namespace-undefine-variable! question

2015-08-27 Thread Deren Dohoda
Hi Jos,
But some of them I want to undefine.
Isn't it easier to make your own restricted #lang and then use
make-module-evaluator? Sorry to butt in.

Deren

On Thu, Aug 27, 2015 at 1:24 PM, Jos Koot jos.k...@gmail.com wrote:

 Thanks for your prompt and clear reply.
 I admit I don't fully understand the map? argument.
 Just by trying out I know that for my purposes I always have to provide
 true for the map? argument.
 Meanwhile I insert the namespace-set-variable-value! line with true map?
 argument, as you suggest.
 Thanks again,
 Jos

 --
 *From:* jensaxelsoega...@gmail.com [mailto:jensaxelsoega...@gmail.com] *On
 Behalf Of *Jens Axel Søgaard
 *Sent:* jueves, 27 de agosto de 2015 17:35
 *To:* Jos Koot
 *Cc:* Racket-Users List
 *Subject:* Re: [racket-users] namespace-undefine-variable! question

 The issue here is whether the namespance's identifier mapping is used or
 not.

 The documentation for namespace-undefine-variable! says:

 Removes the sym variable, if any, in the top-level environment of
 namespace in
 its base phase. The namespace’s identifier mapping (see Namespaces) is
  unaffected.

 We can see that  list  is use the identifier mapping by changing the
 second argument of namespace-variable-value to #f.

 #lang racket
 (define ns (make-base-namespace))
 (namespace-variable-value 'list #f (λ () 'not-found) ns)

 which evaluates to 'not-found.

 Inserting your own non-imported value for  list  makes the identifier
 non-imported and has
 the happy side-effect of making namespace-undefined-variable! capable of
 removing the
 binding from namespace.

 In some sense  namespace-undefined-variable!  miss an map? argument.
 Your solution: insert, then undefine  seem to be the best solution for now.

 /Jens Axel

 you n


 2015-08-27 16:53 GMT+02:00 Jos Koot jos.k...@gmail.com:

 The following works:

 #lang racket/base
 #;1 (define ns (make-base-namespace))
 #;2 (namespace-variable-value 'list #t (λ () 'not-found) ns)
 ; - #procedure:print-syntax-width
 #;3 (namespace-set-variable-value! 'list 'whatever (λ () #f) ns)
 #;4 (namespace-undefine-variable! 'list ns)
 #;5 (namespace-variable-value 'list#t (λ () 'not-found) ns)
 ; - not-found

 But when I omit line 3 it does not work:

 #lang racket/base
 #;1 (define ns (make-base-namespace))
 #;2 (namespace-variable-value 'list #t (λ () 'not-found) ns) ; -
 #procedure:list
 #;4 (namespace-undefine-variable! 'list ns)
 ;- error namespace-undefine-variable!: given name is not defined
 ;   name: list

 This I did with: Welcome to DrRacket, version
 6.2.0.5--2015-07-06(d6fa581/a) [3m].
 Code in the definitions window. The problem is not typical for 'list
 only.
 The same happens with (at least some) other variables of a base-namespace.

 I have no clue why commenting out line 3 gives an error.
 Do I misinterpret the docs on namespaces?

 Thanks, Jos

 PS I use a base-namespace in a toy interpreter.
 It allows me to easily borrow all variables from a base-namespace.
 But some of them I want to undefine.




 --
 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.




 --
 --
 Jens Axel Søgaard

 --
 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.


-- 
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] Re: Continued Fraction Arithmetic Package

2015-08-26 Thread Deren Dohoda
Thanks Vincent, I have done so.

On Wed, Aug 26, 2015 at 12:41 PM, Vincent St-Amour 
stamo...@eecs.northwestern.edu wrote:

 It's easy.

 Just click the login link on the top-right, and create an account.

 Once that's done, you can add your new package to the listing by
 clicking upload. Enter the package meta-information, and have the
 source point to your github repo.

 At that point, anyone will be able to run

 `raco pkg install continued-fractions`

 (assuming you name your package that) and install your library. The
 build status and docs for your package will also be available from
 pkgs.racket-lang.org.

 It's quick, simple and painless, and will make your library easily
 available to anyone.

 Vincent




 On Wed, 26 Aug 2015 10:12:26 -0500,
 Deren Dohoda wrote:
 
  I did not. I wasn't sure what the protocol is there.
 
  Deren
 
  On Aug 26, 2015 11:10 AM, Vincent St-Amour
  stamo...@eecs.northwestern.edu wrote:
 
  Awesome!
 
  Did you add it to pkgs.racket-lang.org? I didn't find it.
 
  Vincent
 
 
 
  On Tue, 25 Aug 2015 21:54:55 -0500,
  Deren Dohoda wrote:
  
   Hello Racketeers,
  
   The continued fractions package has made its first release,
  complete
   with documentation and hopefully enough good examples. You can
  find it
   at
   https://github.com/derend/continued-fractions
  
   Short story:
   (require continued-fractions)
   logs, exponentials, trig, hyperbolic trig, precision guarantees,
   arithmetic (+ - * /)
   (require continued-fractions/bases)
   arbitrary base conversion with user-configurable alphabets
  
   Future plans: add the interface for creating custom continued
  fractions.
   Any user-requested content I am good enough to implement.
  
   Enjoy!
  
   Deren
  
   --
   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.


-- 
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] Re: Continued Fraction Arithmetic Package

2015-08-26 Thread Deren Dohoda
I did not. I wasn't sure what the protocol is there.

Deren
On Aug 26, 2015 11:10 AM, Vincent St-Amour stamo...@eecs.northwestern.edu
wrote:

 Awesome!

 Did you add it to pkgs.racket-lang.org? I didn't find it.

 Vincent



 On Tue, 25 Aug 2015 21:54:55 -0500,
 Deren Dohoda wrote:
 
  Hello Racketeers,
 
  The continued fractions package has made its first release, complete
  with documentation and hopefully enough good examples. You can find it
  at
  https://github.com/derend/continued-fractions
 
  Short story:
  (require continued-fractions)
  logs, exponentials, trig, hyperbolic trig, precision guarantees,
  arithmetic (+ - * /)
  (require continued-fractions/bases)
  arbitrary base conversion with user-configurable alphabets
 
  Future plans: add the interface for creating custom continued fractions.
  Any user-requested content I am good enough to implement.
 
  Enjoy!
 
  Deren
 
  --
  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.


-- 
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] Re: Continued Fraction Arithmetic Package

2015-08-25 Thread Deren Dohoda
Hello Racketeers,

The continued fractions package has made its first release, complete with
documentation and hopefully enough good examples. You can find it at
https://github.com/derend/continued-fractions

Short story:
(require continued-fractions)
logs, exponentials, trig, hyperbolic trig, precision guarantees, arithmetic
(+ - * /)
(require continued-fractions/bases)
arbitrary base conversion with user-configurable alphabets

Future plans: add the interface for creating custom continued fractions.
Any user-requested content I am good enough to implement.

Enjoy!

Deren

-- 
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] Re: DrRacket Scribbles OK, but can't build docs with raco

2015-08-24 Thread Deren Dohoda
I have tracked it down finally to a very stupid error. Some uses of
@examples or @interaction-eval were not given quoted expressions and this
was the problem. It's actually surprising that it works in DrRacket, which
was very misleading.

Deren

On Sun, Aug 23, 2015 at 10:54 PM, Deren Dohoda deren.doh...@gmail.com
wrote:

 I have a scribble document with several examples. When I view the scribble
 html output by using DrRacket, all the examples are fine, the output is
 correct, and I see no errors.

 Then I go to the directory, use raco pkg install, and I get a major text
 dump which starts with cannot instantiate 'racket/gui/base' a second time
 in the same process. But I didn't even try to instantiate it the first
 time. There's no use of gui at all in any part of the collection. I only
 create one evaluator for scribble examples:
 @(define this-eval
(let ([eval (make-base-eval)])
  (eval '(begin
   (require racket/math main.rkt)))
  eval))

 What could I be doing wrong?

 Thanks,
 Deren


-- 
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] Re: DrRacket Scribbles OK, but can't build docs with raco

2015-08-24 Thread Deren Dohoda
Actually quoting it was the wrong thing to do, as I found out when I
finally looked at the docs.

​The docs are not very complicated, if someone could take a look​ at the
cf-manual.scrbl and see if something obvious is going wrong I'd appreciate
it.

https://github.com/derend/continued-fractions/blob/master/continued-fractions/cf-manual.scrbl


Deren

On Mon, Aug 24, 2015 at 11:40 AM, Deren Dohoda deren.doh...@gmail.com
wrote:

 I have tracked it down finally to a very stupid error. Some uses of
 @examples or @interaction-eval were not given quoted expressions and this
 was the problem. It's actually surprising that it works in DrRacket, which
 was very misleading.

 Deren

 On Sun, Aug 23, 2015 at 10:54 PM, Deren Dohoda deren.doh...@gmail.com
 wrote:

 I have a scribble document with several examples. When I view the
 scribble html output by using DrRacket, all the examples are fine, the
 output is correct, and I see no errors.

 Then I go to the directory, use raco pkg install, and I get a major text
 dump which starts with cannot instantiate 'racket/gui/base' a second time
 in the same process. But I didn't even try to instantiate it the first
 time. There's no use of gui at all in any part of the collection. I only
 create one evaluator for scribble examples:
 @(define this-eval
(let ([eval (make-base-eval)])
  (eval '(begin
   (require racket/math main.rkt)))
  eval))

 What could I be doing wrong?

 Thanks,
 Deren




-- 
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] Re: DrRacket Scribbles OK, but can't build docs with raco

2015-08-24 Thread Deren Dohoda
Oh wow I thought I had deleted that long ago. Thank you, that was the
problem.
On Aug 24, 2015 4:11 PM, Robby Findler ro...@eecs.northwestern.edu
wrote:

 I think you need to remove the local-require in the definition of
 to-file in continued-fractions.rkt. This counts as a real require for
 dependency purposes; it just makes the imports scoped locally.
 dynamic-require is the way to get a require that happens only at
 runtime (but in this case, if you decide to keep that function there,
 you probably want to use the racket/gui/dynamic library).

 hth,
 Robby


 On Mon, Aug 24, 2015 at 11:48 AM, Deren Dohoda deren.doh...@gmail.com
 wrote:
  Actually quoting it was the wrong thing to do, as I found out when I
 finally
  looked at the docs.
 
  The docs are not very complicated, if someone could take a look at the
  cf-manual.scrbl and see if something obvious is going wrong I'd
 appreciate
  it.
 
 
 https://github.com/derend/continued-fractions/blob/master/continued-fractions/cf-manual.scrbl
 
 
  Deren
 
  On Mon, Aug 24, 2015 at 11:40 AM, Deren Dohoda deren.doh...@gmail.com
  wrote:
 
  I have tracked it down finally to a very stupid error. Some uses of
  @examples or @interaction-eval were not given quoted expressions and
 this
  was the problem. It's actually surprising that it works in DrRacket,
 which
  was very misleading.
 
  Deren
 
  On Sun, Aug 23, 2015 at 10:54 PM, Deren Dohoda deren.doh...@gmail.com
  wrote:
 
  I have a scribble document with several examples. When I view the
  scribble html output by using DrRacket, all the examples are fine, the
  output is correct, and I see no errors.
 
  Then I go to the directory, use raco pkg install, and I get a major
 text
  dump which starts with cannot instantiate 'racket/gui/base' a second
 time
  in the same process. But I didn't even try to instantiate it the first
  time. There's no use of gui at all in any part of the collection. I
 only
  create one evaluator for scribble examples:
  @(define this-eval
 (let ([eval (make-base-eval)])
   (eval '(begin
(require racket/math main.rkt)))
   eval))
 
  What could I be doing wrong?
 
  Thanks,
  Deren
 
 
 
  --
  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.


-- 
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] DrRacket Scribbles ok, but can't install the docs

2015-08-23 Thread Deren Dohoda
I have a scribble document with several examples. When I view the scribble
html output by using DrRacket, all the examples are fine, the output is
correct, and I see no errors.

Then I go to the directory, use raco pkg install, and I get a major text
dump which starts with cannot instantiate 'racket/gui/base' a second time
in the same process. But I didn't even try to instantiate it the first
time. There's no use of gui at all in any part of the collection. I only
create one evaluator for scribble examples:
@(define this-eval
   (let ([eval (make-base-eval)])
 (eval '(begin
  (require racket/math main.rkt)))
 eval))

What could I be doing wrong?

Deren

-- 
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] DrRacket Scribbles OK, but can't build docs with raco

2015-08-23 Thread Deren Dohoda
I have a scribble document with several examples. When I view the scribble
html output by using DrRacket, all the examples are fine, the output is
correct, and I see no errors.

Then I go to the directory, use raco pkg install, and I get a major text
dump which starts with cannot instantiate 'racket/gui/base' a second time
in the same process. But I didn't even try to instantiate it the first
time. There's no use of gui at all in any part of the collection. I only
create one evaluator for scribble examples:
@(define this-eval
   (let ([eval (make-base-eval)])
 (eval '(begin
  (require racket/math main.rkt)))
 eval))

What could I be doing wrong?

Thanks,
Deren

-- 
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] macro making a struct with a macro

2015-08-17 Thread Deren Dohoda
Thanks for your help Alexander. I did have this much working alright in a
different manner. What I guess I wanted was that this syntax was introduced
per struct so that the same syntax worked for all interface-structs. That
is, if I
(interface-struct test (a b c)
  [(define (some-interface-function ...))
...]) =
(struct test (a b c)
  #:methods gen:???
  [(define-struct-fields (field:id ...) ...)
   (define (some-interface-function ...) ...) ...])

Essentially all it had to do was grab the struct name automatically, just
one more level of indirection. It seemed straightforward but in my example
code the methods defined for the generic interface were not seen.

Deren

On Tue, Aug 18, 2015 at 12:07 AM, Alexander D. Knauth alexan...@knauth.org
wrote:

 Are you looking for a macro like this:
 #lang racket
 (require syntax/parse/define (for-syntax racket/syntax))
 (define-simple-macro (define-struct-fields struct:id (field:id ...) v:expr)
   #:with s (generate-temporary #'struct)
   #:with [struct-field ...]
   (for/list ([field (in-list (syntax-list #'(field ...)))])
 (format-id #'struct ~a-~a #'struct field))
   (begin
 (define s v)
 (define field (struct-field s))
 ...))
 ;; testing it out
 (struct test (a b c))
 (define x (test 1 2 3))
 (define-struct-fields test (a b) x)
 a
 b

 Or do you want it even more automatic than that?

 On Aug 17, 2015, at 11:29 PM, Deren Dohoda deren.doh...@gmail.com wrote:

 Suppose I have a struct which implements a generic interface. I'll copy
 and paste the interface from the guide for the example. What I'd like to do
 is have automatically-introduced syntax which allows you to skip a lot of
 the struct-accessor forms. So for instance, for a struct like
 (struct test (a b c))

 I'd like, in a method, to be able to say
 (define (some-method genericable)
   (define-accessors (a b)))
 Which is essentially a (define-values ...) expression, taking care of the
 messy work of typing out all the accessor methods like (test-a genericable).

 I have this example, which doesn't raise any syntax errors, and looks
 exactly like I'd expect from the macro stepper's output, yet fails when run:

 #lang racket/base
 (require (for-syntax racket/base)
  racket/generic)

 (define-generics printable
 (gen-print printable [port])
 (gen-port-print port printable)
 (gen-print* printable [port] #:width width #:height [height])
 #:defaults ([string?
  (define/generic super-print gen-print)
  (define (gen-print s [port (current-output-port)])
(fprintf port String: ~a s))
  (define (gen-port-print port s)
(super-print s port))
  (define (gen-print* s [port (current-output-port)]
  #:width w #:height [h 0])
(fprintf port String (~ax~a): ~a w h s))]))

 (define-syntax (pstruct stx)
   (syntax-case stx ()
 ((_ struct-name (accessors ...) [body ...])
  (with-syntax ((sv (datum-syntax stx 'struct-values)))
  #'(struct struct-name (accessors ...)
  #:methods gen:printable
  [(define-syntax (sv stx)
 (syntax-case stx ()
   ((_ (acc (... ...)))
(let ((accs (for/list ((id (syntax-datum #'(acc (...
 ...)
  (string-symbol (format ~a-~a 'struct-name
 id)
  (with-syntax ((s (datum-syntax stx 'ps))
(as (datum-syntax stx accs)))
#'(define-values (acc (... ...)) (apply values (map
 (λ(proc) (proc s)) as
   body ...])

 (pstruct test (a b c)
   [(define (gen-print ps)
  (struct-values (a))
  a)])

 Welcome to DrRacket, version 6.2 [3m].
 Language: racket/base [custom]; memory limit: 1024 MB.
  (gen-print (test 1 2 3))
 . . gen-print: not implemented for #test

 How am I going wrong here?

 Thanks,
 Deren

 --
 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.




-- 
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] macro making a struct with a macro

2015-08-17 Thread Deren Dohoda
Suppose I have a struct which implements a generic interface. I'll copy and
paste the interface from the guide for the example. What I'd like to do is
have automatically-introduced syntax which allows you to skip a lot of the
struct-accessor forms. So for instance, for a struct like
(struct test (a b c))

I'd like, in a method, to be able to say
(define (some-method genericable)
  (define-accessors (a b)))
Which is essentially a (define-values ...) expression, taking care of the
messy work of typing out all the accessor methods like (test-a genericable).

I have this example, which doesn't raise any syntax errors, and looks
exactly like I'd expect from the macro stepper's output, yet fails when run:

#lang racket/base
(require (for-syntax racket/base)
 racket/generic)

(define-generics printable
(gen-print printable [port])
(gen-port-print port printable)
(gen-print* printable [port] #:width width #:height [height])
#:defaults ([string?
 (define/generic super-print gen-print)
 (define (gen-print s [port (current-output-port)])
   (fprintf port String: ~a s))
 (define (gen-port-print port s)
   (super-print s port))
 (define (gen-print* s [port (current-output-port)]
 #:width w #:height [h 0])
   (fprintf port String (~ax~a): ~a w h s))]))

(define-syntax (pstruct stx)
  (syntax-case stx ()
((_ struct-name (accessors ...) [body ...])
 (with-syntax ((sv (datum-syntax stx 'struct-values)))
 #'(struct struct-name (accessors ...)
 #:methods gen:printable
 [(define-syntax (sv stx)
(syntax-case stx ()
  ((_ (acc (... ...)))
   (let ((accs (for/list ((id (syntax-datum #'(acc (...
...)
 (string-symbol (format ~a-~a 'struct-name
id)
 (with-syntax ((s (datum-syntax stx 'ps))
   (as (datum-syntax stx accs)))
   #'(define-values (acc (... ...)) (apply values (map
(λ(proc) (proc s)) as
  body ...])

(pstruct test (a b c)
  [(define (gen-print ps)
 (struct-values (a))
 a)])

Welcome to DrRacket, version 6.2 [3m].
Language: racket/base [custom]; memory limit: 1024 MB.
 (gen-print (test 1 2 3))
. . gen-print: not implemented for #test

How am I going wrong here?

Thanks,
Deren

-- 
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] macro making a struct with a macro

2015-08-17 Thread Deren Dohoda
Very helpful, thank you. You're right that the #:methods spec was messing
up the original macro, too. Though it had some other problems after I got
beyond that hurdle.

Every time I think I am starting to understand macros I find out I don't.

Deren

On Tue, Aug 18, 2015 at 12:43 AM, Alexander D. Knauth alexan...@knauth.org
wrote:

 I'm not sure why that doesn't work, but I redid it with my
 define-struct-fields macro factored out and this worked:

 I'm not sure but I suspect the real difference comes from passing
 gen:printable to the pstruct macro though, because that's what causes this
 to fail.
 I also had to add the optional argument to the definition of gen-print in
 the (pstruct test ...) definition.
 The rest was just refactoring as I was trying to see how to simplify it so
 that I could see what was broken and what wasn't.

 #lang racket/base
 (require racket/generic
  syntax/parse/define
  define-struct-fields.rkt
  (for-syntax racket/base syntax/parse racket/syntax))

 (define-generics printable
   (gen-print printable [port])
   (gen-port-print port printable)
   (gen-print* printable [port] #:width width #:height [height])
   #:defaults ([string?
(define/generic super-print gen-print)
(define (gen-print s [port (current-output-port)])
  (fprintf port String: ~a s))
(define (gen-port-print port s)
  (super-print s port))
(define (gen-print* s [port (current-output-port)]
#:width w #:height [h 0])
  (fprintf port String (~ax~a): ~a w h s))]))

 (define-simple-macro (pstruct struct-name (accessors ...) #:methods gen
 [body ...])
   #:with sv (datum-syntax #'struct-name 'struct-values)
   #:with ooo (quote-syntax ...)
   (struct struct-name (accessors ...)
 #:methods gen
 [(define-syntax-rule (sv (fld ooo) v)
(define-struct-fields struct-name (fld ooo) v))
  body ...]))

 (pstruct test (a b c)
   #:methods gen:printable
   [(define (gen-print ps [out (current-output-port)])
  (struct-values (a) ps)
  (print a out))])
 (gen-print (test 1 2 3))

 On Aug 18, 2015, at 12:20 AM, Deren Dohoda deren.doh...@gmail.com wrote:

 Thanks for your help Alexander. I did have this much working alright in a
 different manner. What I guess I wanted was that this syntax was introduced
 per struct so that the same syntax worked for all interface-structs. That
 is, if I
 (interface-struct test (a b c)
   [(define (some-interface-function ...))
 ...]) =
 (struct test (a b c)
   #:methods gen:???
   [(define-struct-fields (field:id ...) ...)
(define (some-interface-function ...) ...) ...])

 Essentially all it had to do was grab the struct name automatically, just
 one more level of indirection. It seemed straightforward but in my example
 code the methods defined for the generic interface were not seen.

 Deren

 On Tue, Aug 18, 2015 at 12:07 AM, Alexander D. Knauth 
 alexan...@knauth.org wrote:

 Are you looking for a macro like this:
 #lang racket
 (require syntax/parse/define (for-syntax racket/syntax))
 (define-simple-macro (define-struct-fields struct:id (field:id ...)
 v:expr)
   #:with s (generate-temporary #'struct)
   #:with [struct-field ...]
   (for/list ([field (in-list (syntax-list #'(field ...)))])
 (format-id #'struct ~a-~a #'struct field))
   (begin
 (define s v)
 (define field (struct-field s))
 ...))
 ;; testing it out
 (struct test (a b c))
 (define x (test 1 2 3))
 (define-struct-fields test (a b) x)
 a
 b

 Or do you want it even more automatic than that?

 On Aug 17, 2015, at 11:29 PM, Deren Dohoda deren.doh...@gmail.com
 wrote:

 Suppose I have a struct which implements a generic interface. I'll copy
 and paste the interface from the guide for the example. What I'd like to do
 is have automatically-introduced syntax which allows you to skip a lot of
 the struct-accessor forms. So for instance, for a struct like
 (struct test (a b c))

 I'd like, in a method, to be able to say
 (define (some-method genericable)
   (define-accessors (a b)))
 Which is essentially a (define-values ...) expression, taking care of the
 messy work of typing out all the accessor methods like (test-a genericable).

 I have this example, which doesn't raise any syntax errors, and looks
 exactly like I'd expect from the macro stepper's output, yet fails when run:

 #lang racket/base
 (require (for-syntax racket/base)
  racket/generic)

 (define-generics printable
 (gen-print printable [port])
 (gen-port-print port printable)
 (gen-print* printable [port] #:width width #:height [height])
 #:defaults ([string?
  (define/generic super-print gen-print)
  (define (gen-print s [port (current-output-port)])
(fprintf port String: ~a s))
  (define (gen-port-print port s)
(super-print s port

[racket-users] Continued Fraction Arithmetic Package

2015-08-15 Thread Deren Dohoda
Hi Racketeers,

I'm working on a continued fraction arithmetic package for arbitrary
precision arithmetic. I have the basics implemented and functioning and
would like to know which features people would like available as an
interface, and I'll see if I can provide it.

What you can already expect I will provide:
1) continued fractions as sequences
2) construction of arbitrary continued fractions, rational (finite) or
irrational*
3) addition, subtraction, multiplication, division of continued fractions
as sequence-sequence procedures; e.g. (cf-times pi pi) - sequence
4) precision control, via a parameter, to not generate more terms than a
given precision**
5) rational functions for sine, cosine, tangent, exp, natural log, rational
exponents of rational numbers
6) emission of terms in simple continued fraction form i.e. terms are the
sequence of denominators, assuming 1 is a numerator
7) emission of terms of an arbitrary base = 2***

Note: continued fraction arithmetic is compositional but irrational
arguments to irrational functions are not compositional without
computationally major backtracking, so you can have pi to arbitrary
precision and sine functions to arbitrary precision but I do not know how
to straightforwardly compute general expressions like sin(pi/3) to
arbitrary precision. If there is a way someone can point me to I would love
them forever, but my guess is that it is not possible except for
preconceived expressions for which one has calculated propagation of error
formulas.

Also note: computations which take irrational arguments but would yield a
rational answer will spin forever, so there is a limit (as a parameter)
which forbids such infinite loops and will spit out something.

These are the main features I would intend as a single collection.

This is my second pass at such a library, made so that it is much faster
than its original form I worked on a few years ago. If there is interest I
would be happy to re-implement and release features I've used in my first
library, like conversion between arbitrary number bases with user-supplied
alphabets (fun for finding all the words in the expansion of pi if this
suits your fancy). If so, then I'd likely release this as a
multi-collection package so this feature is optional.

Deren

* Truly arbitrary continued fractions will necessarily and unavoidably
invalidate precision bounds due the behavior of suddenly-negative terms or
zeros which do not occur normally; and, for that matter, the convergence of
general continued fractions is an unsolved problem. Those continued
fractions or functions which produce continued fractions which will be
provided by the library will always be well-behaved.

** These are currently implemented like odd streams in that inner
sequences are one-ahead from the main sequence; also, this precision is up
to a factor and therefore never worse but likely better than requested

*** Since there is no natural separator in a sequence of terms, the integer
part is emitted without respecting base; subsequent terms will always be
base-n terms. This is definitely negotiable if an adequate representation
can be found that doesn't overly complicate their use as sequences. I
couldn't think of one, so I didn't try anything for the sake of it.

-- 
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] #lang languages and REPL

2015-08-07 Thread Deren Dohoda
Short version: __Thank you__

It does appear that I do not need the #%module-begin rewrite in this test
case. However, the point of the language is to create a dictionary of
procedures and provide a run procedure which accepts a symbol and returns
the procedure in the dictionary. My concern was what would happen if
multiple files of this language were required at one time, that the
dictionary would contain references to all these functions, which might
have the same key. So, I thought I had to put the dictionary and run
procedures in the %#module-begin rewrite. If I eliminate the #%module-begin
rewrite, then multiple files will add their procedures to the same
underlying dictionary which could cause an unnecessary collision in a
practical example.

But, that's a long way to say that you are right, the problem was naming
scope. After using a with-syntax rewrite then it is behaving as expected in
the REPL.

Thanks for your help.

Deren

On Fri, Aug 7, 2015 at 5:45 PM, Alexander D. Knauth alexan...@knauth.org
wrote:


 On Aug 7, 2015, at 4:35 PM, Alexander D. Knauth alexan...@knauth.org
 wrote:

 The definition of x in `my-module-begin` doesn't work because it comes
 from the macro's scope, not from the module's scope.
 See
 http://docs.racket-lang.org/reference/syntax-model.html#%28part._macro-introduced-bindings%29

 If you really need to use that approach instead of what I suggested above,
 you should be able use either syntax-local-introduce or datum-syntax.
 You could try building off of one of these: (not tested)

 (require syntax/parse/define)
 ;; one option, using syntax-local-introduce:
 (define-simple-macro (my-module-begin body ...)
   #:with x-id (syntax-local-introduce #'x)
   (#%module-begin
(define x 2)


 Sorry I meant (define x-id 2)

body ...))
 ;; another option, using syntax-local-introduce:
 (define-syntax my-module-begin
   (lambda (stx)
 (syntax-case stx ()
   [(_ body ...)
(with-syntax ([x-id (syntax-local-introduce #'x)])
  #'(#%module-begin
  (define x 2)


 And here too, (define x-id 2)

  body ...))])))
 ;; another option, using datum-syntax:
 (define-syntax my-module-begin
   (lambda (stx)
 (syntax-case stx ()
   [(_ body ...)
(with-syntax ([x-id (datum-syntax stx 'x)])
  #'(#%module-begin
  (define x 2)


 And here, (define x-id 2)

  body ...))])))

 Hope this helps!

 Alex Knauth




-- 
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] #lang languages and REPL

2015-08-07 Thread Deren Dohoda
I have a #lang I'm working on and everything seems to be going very well. One 
thing I don't understand, though, is that when a file written in this language 
is opened in DrRacket and Run, I still have to (require file.rkt) in the REPL 
before I am able to use anything provided by the file.

I assume that I am neglecting to do something somewhere related to the use of 
#%top-interaction, because when I fail to provide this from the implementation 
of the language, I cannot run the file in DrRacket at all. But merely adding it 
to the provide expression doesn't do what I expect.

Any help?

Deren

-- 
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] #lang languages and REPL

2015-08-07 Thread Deren Dohoda
I
​ have a minimal example that reproduces the behavior and I can track it
down to the fact that I do not export define and the file which uses the
new #lang does not define anything, except through a #%module-begin
rewrite. If the file written in the new #lang has access to define and
defines anything, then indeed it shows up. Please forgive any gmail
formatting:

TEST/
--test.rkt​
--test-lang/
test-lang.rkt
lang/
--reader.rkt

I add the TEST directory to PLTCOLLECTS.

reader.rkt:
#lang s-exp syntax/module-reader
test-lang/test-lang.rkt

test-lang.rkt:
#lang racket/base
(provide (rename-out (my-module-begin #%module-begin))
 #%app #%top #%datum #%top-interaction
 require displayln)

(define-syntax-rule (my-module-begin body ...)
  (#%module-begin
   (define x 2)
   (provide x)
   body ...))

test.rkt:
#lang test-lang
(displayln 2)

Run test.rkt
Welcome to DrRacket, version 6.2 [3m].
Language: test-lang [custom]; memory limit: 4096 MB.
2
 x
. . x: undefined;
 cannot reference an identifier before its definition
 (require test.rkt)
 x
2
​;

It seems to be because of the definition of x in my-module-begin. But I
don't understand why this doesn't work.

Thanks for any insight here, I seem to have a bad mental model of what's
happening,
Deren​


On Fri, Aug 7, 2015 at 4:32 PM, Alexander D. Knauth alexan...@knauth.org
wrote:

 That sounds weird. You shouldn't need to do anything special with
 #%top-interaction or anything, so I'm not sure what's going on.

 How are you defining it?  Can you show us some of the source code?

 On Aug 7, 2015, at 1:09 PM, Deren Dohoda deren.doh...@gmail.com wrote:

  I have a #lang I'm working on and everything seems to be going very
 well. One thing I don't understand, though, is that when a file written in
 this language is opened in DrRacket and Run, I still have to (require
 file.rkt) in the REPL before I am able to use anything provided by the
 file.
 
  I assume that I am neglecting to do something somewhere related to the
 use of #%top-interaction, because when I fail to provide this from the
 implementation of the language, I cannot run the file in DrRacket at all.
 But merely adding it to the provide expression doesn't do what I expect.
 
  Any help?
 
  Deren
 
  --
  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.



-- 
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] Some help with syntax-parse: macro in macro

2015-07-31 Thread Deren Dohoda
Suppose I have a macro (experiment ...) which is intended, among other things, 
to be composed of uses of a macro (collect ...). 

For instance:
(experiment
  (collect ...)
  (collect ...) ...)

To my understanding, collect is not a literal. Can I turn the collect macro 
itself into a syntax class somehow? Should I instead create a dummy literal 
collect for this purpose, and then create a (collect* ...) macro?

Thanks for any advice.

Deren

-- 
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] Some help with syntax-parse: macro in macro

2015-07-31 Thread Deren Dohoda
Hi Stephen,

At the moment, collect is syntax, itself defined through syntax-parse. So
you suggest making collect a literal and changing the underlying macro
name?

It's part of a #lang experiment I'm writing which manages a series of
actions from a controller. The file, when required, provides a (run
controller model) procedure which takes a controller for executing (collect
...) actions and a model to store the data returned by the (collect ...)
output.

Right now what I have is something like this with some cluttering details
omitted
#lang experiment
(define-experiment
  (collect uv #:points 10 #:seconds 2) ; collect a point every 2 seconds 10
times
  (collect uv #:points 10 #:minutes 30)
  ...)

But it does no checking that it is called with anything other than
(define-experiment exps ...) which is Not Good.

This will eventually morph into something much more detailed, like
#lang experiment
(define-experiment
  (with-reference ; optional
(with-standard ; optional
  (collect uv #:points 10 #:seconds 10)
  (collect uv #:points 20 #:minutes 1)))
  (with-reference ; optional
(collect uv #:points 10 #:seconds 10)
(collect uv #:points 20 #:minutes 1)
(collect uv #:points 30 #:hours 1)))

And the (define-experiment ...) macro will need to reorder all this so it
makes sense in how a person interacts with a device. Describing an
experiment and running it are usually very different! So whatever strategy
is adopted for collect will multiply quickly.

I remember reading about how there are some gotchas with treating macro
names as literals in patterns (maybe this is a syntax-case problem?) and I
wanted to avoid just assuming things.

Deren

On Fri, Jul 31, 2015 at 12:05 PM, Stephen Chang stch...@ccs.neu.edu wrote:

 You might want to specify collect in #:datum-literals if it is not a
 defined name.

 Can you describe some usage examples? That may lead to better insight
 for the implementation.

 On Fri, Jul 31, 2015 at 11:49 AM, Deren Dohoda deren.doh...@gmail.com
 wrote:
  Suppose I have a macro (experiment ...) which is intended, among other
 things, to be composed of uses of a macro (collect ...).
 
  For instance:
  (experiment
(collect ...)
(collect ...) ...)
 
  To my understanding, collect is not a literal. Can I turn the collect
 macro itself into a syntax class somehow? Should I instead create a dummy
 literal collect for this purpose, and then create a (collect* ...) macro?
 
  Thanks for any advice.
 
  Deren
 
  --
  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.


-- 
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] scribble namespace landgrab embedded package documentation

2015-05-08 Thread Deren Dohoda
How does this really differ from literate programming?

Deren
On May 4, 2015 7:39 PM, Neil Van Dyke n...@neilvandyke.org wrote:

 For purposes of embedding docs for a package in its Racket source file(s),
 anyone care whether I landgrab some names in the Scribble namespace (for
 package metadata)?

 I'm thinking the names will generally one-word generic terms, but with
 capitalization.

 Example package source file with said metadata:

  BEGIN 

 #lang racket/base
 ;;; @Package{duckling}
 ;;; @Version{0.1}
 ;;; @Subtitle{Small-Footprint Web Server in Racket}
 ;;; @Author{Neil Van Dyke}
 ;;; @Author{Alyssa P. Hacker}
 ;;; @License{LGPLv3}
 ;;; @Legal{Copyright 2015 Neil Van Dyke.  This program is Free Software;
 ;;;   you can redistribute it and/or modify it under the terms of the
 ;;;   GNU Lesser General Public License as published by the Free
 ;;;   Software Foundation; either version 3 of the License, or (at your
 ;;;   option) any later version.  This program is distributed in the
 ;;;   hope that it will be useful, but without any warranty; without
 ;;;   even the implied warranty of merchantability or fitness for a
 ;;;   particular purpose.  See http://www.gnu.org/licenses/ for details.
 ;;;   For other licenses and consulting, please contact the author.}

 (require (for-syntax racket/base))

 ;;; @section{Introduction}

 [CODE INTERSPERSED WITH THREE-SEMICOLON SCRIBBLE GOES HERE]

 ;;; @History{
 ;;;
 ;;;   @Release[0.1 2014-12-31]{
 ;;; Initial release.}
 ;;; }

  END 

 Rationale:

 * I'm thinking of using the Racket reader for metadata, instead of some
 special-cased text kludge for the metadata, for simplicity/elegance of
 implementation.

 * I'm using three-semicolon comments instead of McFly's `doc` forms, to
 simplify evaluation, and to make visually distinguishing between doc and
 code easier without special editor support.

 * I've moved the metadata from `info.rkt` back into source file, to make
 only one file you have to edit per package (the redundant bits of
 `info.rkt`, like package name and description, can be updated automatically
 using http://www.neilvandyke.org/racket-progedit/;). Also, when packages
 were forked under McFly, the legal notice in `mcfly-legal` variable in
 `info.rkt` tended to get lost, and lawyers like you to put the notice on
 the actual file anyway (rather than my old ;; See file info.rkt for legal
 info. kludge comment at the tops of key files).

 Incidentally, if you paste that example code into Emacs with Quack, you
 should see remnants of 13-year-old support for my earlier embedded Texinfo
 format: http://postimg.org/image/wuwy376od/
 (Though I preferred the look of comments when they were light blue, like
 in DrScheme v103, instead of the modern yellow-snow. :)

 Neil V.

 --
 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.


-- 
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] raco make, file permissions, and unstable directories

2015-04-19 Thread Deren Dohoda
Thanks Robby  and Matthew.  I use relative or runtime-computed paths myself
so it looks like everything is clear. I do need to consider how to manage
different Racket builds, right now I have stuck with the same build but
updating Racket is something I will need to manage.

Deren
On Apr 16, 2015 3:03 AM, Robby Findler ro...@eecs.northwestern.edu
wrote:

 1) Compilation to .zo files (what raco make does) can theoretically
 embed absolute paths, but this is something we work hard to avoid, so
 it shouldn't be happening. We use the ability to move .zo files around
 when building our distributions, for example, so I think you should be
 safe. (But there can be bugs, of course.)

 The theoretical possibility exists because a macro runs arbitrary
 racket code to compute its output and then can embed arbitrary stuff
 from the context into the result of its expansion, including
 information about the path where compilation happens. But I really do
 think you can rely on this not happening unless you write your own
 macros that make it happen.

 2) no, that seems fine. As long as you have the same version of the
 racket executable, the .zo files will work. (And if you don't, you'll
 get an error message pointing out the version mismatch.)

 Robby



 On Wed, Apr 15, 2015 at 12:50 PM, Deren Dohoda deren.doh...@gmail.com
 wrote:
  Hi group,
 
  I use Racket in an embedded linux system. My normal development process
 is
  to write Racket code in Windows, transfer this to the embedded computer,
 and
  then use raco make in the Debian system. But when the system is powered
 on,
  it doesn't boot to Debian, it boots to a busybox OS where the filesystem
 is
  read-only, and the paths are not the same.
 
  To this end, the busybox OS runs a startup script which calls racket
  directly to run the main file. This all works fine, but I have started to
  wonder about two things:
 
  1) does raco make build in any absolute path dependencies? Should I
 instead
  remount the filesystem as read/write in busybox and run raco make
 there,
  since the busybox filesystem has different paths than the Debian
 filesystem?
 
  2) suppose I run raco make on a board and copy the result out to a USB
 stick
  with a FAT filesystem which can't preserve things like execute
 permissions,
  then copy this back to a new board. Should I expect that the racket
  executable will have some problems with the previously-used compiled
  folders?
 
  Thanks for any insight here.
 
  Deren
 
  --
  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.


-- 
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.