[racket-users] F1 key for custom language

2020-11-17 Thread Dmitry Pavlov

Hello,

When I press F1 in DrRacket, I get a nice new browser tab with search 
results from ~/.racket//doc/ directory.


I would like to have a thing like this for my custom non-sexp language. 
So I am going to write some Scribble, and then... will it be 
automatically searchable after I install my Scribble docs via raco, or 
should I override something DrRacket-specific in my language 
definitions?


How can I prioritize the search results so that when F1 is pressed in a 
#lang mylang file, the non-mylang search results are shown second, or 
are not shown at all?


Best regards,

Dmitry

--
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/2385c6bb229c761fe5b510da0b5859ea%40iaaras.ru.


Re: [racket-users] file-position in Win32 not working beyond 1 GB

2019-12-27 Thread Dmitry Pavlov
Matthew,

Only today I managed to get back to that problem.
But your effort of making a special executable for me still turned out to be 
relevant.
Because on my good ol' Windows XP machine, the Utah i386 nigtly build, while 
installing successfully, resulted in a Racket executable that the system 
refused to run, saying that it is not a correct executable. (The message was 
localized in Russian so I am not sure what is the exact English original 
message). Same situation with raco.exe so it must be something systematic.

And your special build works fine. And older stock Racket 7.1 worked fine too.

I can totally live without WinXP, just curious whether it is a planned 
behaviour.

Best regards,

Dmitry

On December 22, 2019 9:22:40 PM EET, Matthew Flatt  wrote:
>At Sun, 22 Dec 2019 20:28:41 +0300, Dmitry Pavlov wrote:
>> 
>> > Thanks! It really is a bug in `scheme_get_long_long_val`, where the
>> > extraction can read past the end of a bignum on a 32-bit platform.
>> >
>> > Repair pushed.
>> Great, thank you!
>> Given that I do not normally build Racket, should I wait for the next
>snapshot 
>> from UoU or Northwestern to check out the repaired version?
>> 
>> Or any of the two?
>
>Yes --- but the Northwestern snapshot site is having trouble, so it
>will be at the Utah site in about 24 hours.
>
>In case it helps to run earlier, here's a one-off snapshot:
>
> http://www.cs.utah.edu/~mflatt/tmp/racket-7.5.0.14-i386-win32.exe
>
>-- 
>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/5dffb472.1c69fb81.629ef.25a0SMTPIN_ADDED_MISSING%40gmr-mx.google.com.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/33B51AEC-3844-4E0C-BAFC-89833FC1B20E%40iaaras.ru.


Re: [racket-users] file-position in Win32 not working beyond 1 GB

2019-12-22 Thread Dmitry Pavlov




Thanks! It really is a bug in `scheme_get_long_long_val`, where the
extraction can read past the end of a bignum on a 32-bit platform.

Repair pushed.

Great, thank you!
Given that I do not normally build Racket, should I wait for the next snapshot 
from UoU or Northwestern to check out the repaired version?

Or any of the two?

Best regards,

Dmitry


--
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/5dcb7e32-a422-d4f0-eb01-000a65dc983a%40iaaras.ru.


Re: [racket-users] file-position in Win32 not working beyond 1 GB

2019-12-21 Thread Dmitry Pavlov




There could be something wrong with `scheme_get_long_long_val`, but
it's surprising that it could go wrong in a machine-specific way.

Does the error happen for you even in a very short program that tries
to set the file position to 1122398240, or does it only happen in your
full program?


I just did some debug printing.

The problem is more complicated than I thought.
I was misled by the "too large" diagnostics message and thought that the 
problem is just the number, but it is not, or at least not only the number.

The error pops out not on the first or second positioning exceeding 1 GB. In 
fact, it happens on different moments in different runs.

This time, for instance, it happened on position 1120708256.
Interesntigly, moments ago the positioning on the same number, and also with 
different numbers, on the same file, several times, did not raise an error. 
Here is the tail of the sequence of positioning numbers on the same file that 
ended with the error:

1120708256
46696208
46696208
46696208
1120708256
46696208
46696208
46696208
1120708256
46696208
46696208
46696208
1120708256 ---> error

(other files were also positioned alternately with this one; not sure if it is 
important).

Despite the presence of numbers < 1 GB in the sequence, the error always 
happens on numbers greater than 1 GB

I never had a problem with the same program on 64-bit Linux.

I can do some more tests if you need them. I could use a hint about what kind 
of test would be useful to track down the problem.

Best regards,

Dmitry


--
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/5cddd0ee-9c39-600b-2f1b-0ae7b60db37c%40iaaras.ru.


Re: [racket-users] file-position in Win32 not working beyond 1 GB

2019-12-20 Thread Dmitry Pavlov





The Racket-imposed limit should be 64 bits (more than enough) on all
platforms. I can try to replicate the problem later today, but more
information on the error message would be helpful.

I do not have access to that Windows 7 machine until Monday.
I managed to reproduce the problem, though, on a 32-bit Windows XP with 
Racket 7.1.


file-position: new position is too large
  port: #
  position: 1122398240

Best regards,

Dmitry

--
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/141a6202-4853-e189-afd9-8f09b4687507%40iaaras.ru.


Re: [racket-users] file-position in Win32 not working beyond 1 GB

2019-12-20 Thread Dmitry Pavlov



I would have understood maximum the limit of maximum signed integer 
2^31 = 2 GB (and my program would be fine with 2 GB limit).
meant to be "I would have understood the limit of maximum signed integer 
..."


--
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/5227f059-20fa-13de-8c3e-d765f14215eb%40iaaras.ru.


Re: [racket-users] file-position in Win32 not working beyond 1 GB

2019-12-20 Thread Dmitry Pavlov





On a fresh 32-bit Racket 7.5 install on 32-bit Windows 7,
(file-position port number) does not work when number
is more that 1 GB.


On 32-bit machines, the largest fixnum is 2^30  which is 1GB.  I 
suspect that /file-position/  really wants a fixnum rather than a 
non-negative-integer as is documented.


That would be sad because it essentially renders my program non-runnable 
on 32-bit Windows.


To those who know about how (file-position) works: has it always been 
that way?
I know that 32-bit systems are not cool nowadays, but they are still in 
use on some of my colleagues' machines.


Also, I do not quite buy the 1 GB limit even on a 32-bit system.
I would have understood maximum the limit of maximum signed integer 2^31 
= 2 GB (and my program would be fine with 2 GB limit).


Best regards,

Dmitry

--
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/7fe1b7ce-3fa4-cdef-c5bf-310250fcf4fd%40iaaras.ru.


[racket-users] file-position in Win32 not working beyond 1 GB

2019-12-20 Thread Dmitry Pavlov

Hello,

On a fresh 32-bit Racket 7.5 install on 32-bit Windows 7,
(file-position port number) does not work when number
is more that 1 GB.

I can not now say exactly what the error message was,
because I am away from that system, but IIUC it
was something about the position being "too large".

The size of the file, though, is definitely large enough
to have that position, and (file-position port number)
on it worked fine until the number grew beyond
the said limit.

On 64-bit Linux, everything is fine.

Can I work this problem around somehow?

Best regards

Dmitry

--
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/22f36172-daf8-7e6f-5f55-9e1c562b8b61%40iaaras.ru.


Re: [racket-users] Code generation options for a self-made compiler

2019-08-20 Thread Dmitry Pavlov

Matthew,

Thank you and Matthew Butterick for advice. I was offline for a while.

I did not know about raco-commands. I think this is a reasonable 
compromise for my task. I am not concerned about co-existence of files 
produced by the compiler in different modes.


I am not sure I got the idea about DrRacket, though. You wrote:


Your tool would use `make-compilation-manager-load/use-compiled-handler`


In what way my tool would use that?
To be clear, I care about my own options (C/Racket code and 
64-bit/80-bit reals) rather than the options that DrRacket currently 
provides to user.


In "Language->Choose language" I see different options provided to me 
depending on whether I choose "The Racket Language" or "Teaching 
Languages" or "Other Languages". So it gives me and idea that there is 
some flexible mechanism for options setting underneath.


If I am mistaken, that is not critical -- I can program in DrRacket with 
some "default" options for my language and use the non-default options 
when starting from command line.


Best regards,

Dmitry


On 08/15/2019 11:03 AM, Matthew Flatt wrote:

I don't have a great answer for this situation, either.


If the compilation mode makes sense as a global configuration of an
installation, then one possibility would be to add to
"etc/config.rktd". Editing that file is less convenient in some ways
than command-line arguments, but it's nicer in other ways, since it
makes it less likely that mismatches will result from failing to
configure every compilation and execution the same way.


I can elaborate on the possibility of imitating DrRacket's compilation
modes, although I'm not sure it's a good idea for your case.

DrRacket sets `use-compiled-file-paths` based on the GUI-selected mode,
adding a mode-specific subdirectory before the default subdirectory,
and then uses `make-compilation-manager-load/use-compiled-handler` to
get the effect of `raco make`. Crucially, though, DrRacket also sets
`current-path->mode` to decide, for each module, whether to write to
the mode-specific subdirectory or the default subdirectory; otherwise,
too many installed modules would be compiled to a mode-specific
subdirectory, while DrRacket wants only your files (based on a
heuristic for which files are yours) to be compiled in a mode-specific
way.

So, you could do something like that, and maybe even have your C-code
generation depend on the value of `use-compiled-file-paths`. But then
you also need to set `use-compiled-file-paths` before running your
program; one possible obstacle is that there's not currently a `racket`
command-line argument to do that.


If you don't care about having results of multiple compilation modes
coexist --- which seems likely --- then Matthew Butterick's suggestion
to create a variant of `raco make` makes sense to me, although it does
seem heavyweight and not composable. Your tool would use
`make-compilation-manager-load/use-compiled-handler`, but not need to
set `use-compiled-file-paths`. It could accept extra options as a way
to avoid environment variables and communicate some other way to the
code generator, but I'm not sure what the better way would be.


At Mon, 12 Aug 2019 17:34:34 +0300, Dmitry Pavlov wrote:

Hello,

I posted this question once, nobody answered, this is a second try.
I believe there should be a solution because the problem seems rather common.

See, I have a DSL compiler implemented in Racket as a #lang, syntax-parse etc.
Like most compilers, it can emit somewhat diifferent code from the same input
program depending on user's needs.
I am looking for a way to specify those needs to the compiler.

Specifically, I have a backend for C code generation and another backend for
generating Racket syntax objects. I have an option to emit numerical code with
64-bit or 80-bit floating point numbers.

DrRacket has some GUI engine for compiler parameters (debugging, populate
"compiled" directories etc), but I do not know how to use them in raco make,
let alone bring my own options to DrRacket or raco make.

With C, everyone is happy with macros and built-in options, e. g.

gcc -O3 -DREAL=double -DDATABASE=POSTGRES prog.c


The best idea for Rackey I have so far is to use good old environment
varibles, e. g.

REAL=double BACKEND=Racket raco make myprog.mylang

But it has its obvious drawbacks. What do I do instead?

Best regards,

Dmitry

--
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/1E315A92-E90E-45F5-99C6-94AF25F3
25B3%40iaaras.ru.


--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and stop receiving emai

[racket-users] Code generation options for a self-made compiler

2019-08-12 Thread Dmitry Pavlov
Hello,

I posted this question once, nobody answered, this is a second try.
I believe there should be a solution because the problem seems rather common.

See, I have a DSL compiler implemented in Racket as a #lang, syntax-parse etc.
Like most compilers, it can emit somewhat diifferent code from the same input 
program depending on user's needs.
I am looking for a way to specify those needs to the compiler.

Specifically, I have a backend for C code generation and another backend for 
generating Racket syntax objects. I have an option to emit numerical code with 
64-bit or 80-bit floating point numbers.

DrRacket has some GUI engine for compiler parameters (debugging, populate 
"compiled" directories etc), but I do not know how to use them in raco make, 
let alone bring my own options to DrRacket or raco make.

With C, everyone is happy with macros and built-in options, e. g.

gcc -O3 -DREAL=double -DDATABASE=POSTGRES prog.c


The best idea for Rackey I have so far is to use good old environment varibles, 
e. g.

REAL=double BACKEND=Racket raco make myprog.mylang

But it has its obvious drawbacks. What do I do instead?

Best regards,

Dmitry

-- 
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/1E315A92-E90E-45F5-99C6-94AF25F325B3%40iaaras.ru.


Re: [racket-users] finding the expander at run-time

2019-08-05 Thread Dmitry Pavlov

Hello,

Your task reminds me of the one I had some time ago, and the found 
solution is still used to this day.
You can see the old thread here: 
https://groups.google.com/forum/#!msg/racket-users/ATXEyp-4AJA/x0KHbeOhdFwJ


I am not sure it is compatible right away with what you are doing:
there is not "eval" there, but "eval-syntax"; also, dedicated 
(require-input-port)
and (prefix-input-port) procedures, written by Matthew, are used to 
exempt users of #lang line.


As for your problem with raco exe, see Matthew's suggestion to make a 
(dummy) my-package/main

and then do ++lib my-package/main, maybe it will help in your case, too.

Regards,

Dmitry



On 08/04/2019 09:40 PM, Jesse Alama wrote:

I'm working on a #lang and having some trouble with run-time paths.

Before I desparately type increasingly improbable combinations of
tenuously related thing hoping that the next invocation will be the
right one, I thought I'd write here. I've tried looking around on the
mailing list archives for help, but I can't quite find what I'm looking
for. My problem is surely not new, so I apologize if I'm inadvertantly
re-asking a question with a well-known answer. If this has already been
definitively answered here or somewhere else, I'm happy with a link to
the discussion.

For context: the users of my #lang aren't Racket programmers, don't know
of Racket, and shoulnd't have to. I'm building a command line tool. It's
made with Racket, of course, but it's essential that this tool not
require DrRacket, and should not require command line invocations like
"racket my-cool-thing.rkt filename.whatever". It should work like this:

   $ coolthing file.whatever

where coolthing is my compiled Racket program.

I get that there are ways of making executables, but I'm getting
confused about paths. Specifically, the path for my expander.

My code works as a proper #lang. That is, I can happily work with it in
DrRacket, and I get a REPL for free. That's really great. But, again,
there should be no (immediately visible) Racket dependency.

Here's what I've got:

* expander.rkt: the expander. Provides definitions according to which
   raw S-expressions get their meaning.

* info.rkt: present, but contains -- to my knowledge -- nothing
   especially relevant. (I almost omitted info.rkt from this list,
   thinking it was definitely irrelevant, but then it occurred to me that
   I may need to add some paths here.)

* grammar.rkt: Brag grammar (provides parse)

* secret.rkt: the principal program. Uses command-line, takes a filename
   as its sole argument, parses it using grammar.rkt, and is intended to
   execute the program along the lines of expander.rkt.

When I work in DrRacket, I know that a couple other files (main.rkt,
reader.rkt for read-syntax) are being used. I omitted them from this
list because (I think) they're not necessary for what I'm trying to
do. (But who knows: that may be where I'm wrong.)

In secret.rkt I've essentially got this:

   (define program (parse path))
   (parameterize ([current-namespace (make-base-empty-namespace)])
  (namespace-require '(file "expander.rkt"))
  (eval program))

This works at the command line (if I'm in the right directory) using

   racket client.rkt whatever.foo

but fails when the program is compiled using raco exe:

   open-input-file: cannot open module file
 module path: /Users/jesse/secret/examples/expander.rkt
 path: /Users/jesse/sources/secret/examples/expander.rkt
 system error: no such file or directory; rktio_err=3

It's clear to my that this fails, and why. The expander is missing. If I
try to be more clever and replace the '(file "expander.rkt") with '(lib
...) -- so that it looks like this:

   (define program (parse path))
   (parameterize ([current-namespace (make-base-empty-namespace)])
  (namespace-require '(lib "my-package/expander"))
  (eval expanded))

then I get aother error:

   standard-module-name-resolver: collection not found
 for module path: (lib "secret/expander")
 collection: "secret"
 in collection directories:
  /Users/jesse/secret/lib/plt/secret/collects

I've tried things like using ++lib with raco exe and ++collects-copy
with raco distribute, but I can't figure it out; I always get something
essentially equivalent to: "Can't find your expander.". I feel up
against the ropes: adding a main module to expander.rkt so that
command-line processing happens there (!). That feels pretty weird, but
maybe that would work. (Did I mention that I'm turning to increasingly
improbable ideas in my quest for a solution?) I'm sure I'm missing
something really simple here. Any ideas?

Jesse



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

Re: [racket-users] Why struct type doesn't include field names?

2019-06-15 Thread Dmitry Pavlov





But yes, this is directly related to the discussion above because with the 
field name information, you can write your own accessor.


Yes it will be a way to go in Racket 2.



But for now, https://docs.racket-lang.org/struct-define/index.html might be a 
good workaround for your problem.


Thank you, I did not know about it. define-struct-define is indeed very handy.

Best regards,

Dmitry


--
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/6d906345-1ce0-0c95-55b6-9dd5dd346bbf%40iaaras.ru.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Why struct type doesn't include field names?

2019-06-14 Thread Dmitry Pavlov

Hello,

While we are at it: is it theoretically possible in Racket or Typed Racket (or 
will be possible in Racket 2 or Typed Racket 2) to access struct fields without 
repeating the name of the struct type again?

Like in C

typedef struct
{
  double x;
  double y;
} VeryLongStructureName;

VeryLongStructureName a;

double z = a.x + a.y;


The analogous Racket code for the last line would be

(define z (+ very-long-structure-name-x a) (+ very-long-structure-name-y a))

and I am wondering whether it can be shortened to something like (define z (+ 
(. x a) (. x b)))

(I know that match can work with structs, but it is not always as convenient as 
the C way with the dot)


Best regards,

Dmitry


--
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/d23df714-e808-91f3-b978-29bcca849100%40iaaras.ru.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Compiler options for a DSL

2019-05-30 Thread Dmitry Pavlov

Hello,

Racket is a perfect tool for creating new languages and compilers
for them, everybody knows that.

There is one thing, though, generally available in compilers and
not instantly available in Racket DSL tools (or I just missed it).

How to specify options to the compiler?

Consider a source file `prog.mylang`, a `mylang/lang/reader.rkt`
properly set up, `racket prog.mylang` and `raco make prog.mylang`
working as expected.

Now, suppose I want to pass a specific option to the mylang
implementation when I compile `prog.mylang`, but not as a part
of the program source code or compiler source code.
For instance, "emit logging commands",
or "set external constant N = 100",
or "generate C instead of Racket syntax objects".

How would you recommend I do that?
(Preferably in both DrRacket and command line, but at this
point I will be happy enough with just command line.)


Best regards,

Dmitry

--
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/d32fbf48-c04a-9cef-1e8e-58fe9e4d2291%40iaaras.ru.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] anyone using single-flonums?

2019-05-29 Thread Dmitry Pavlov




My guess is that no one uses them currently, because it's rare that
you'd want to trade speed for *im*precision. Single-flonums in Racket
are significantly slower than regular flonums, because they're not
treated as a common case. The only use I can think of, and the one that
inspired the original experiment, is to try to faithfully replicate a C
`float` calculation in Racket, but even that possibility has issues.



To my knowledge, one reason to use single-precision numbers is
that they occupy half as much memory, which is a big deal
in e. g. video games and signal processing applications.

No, I do not use them myself in Racket.

Regards,

Dmitry

--
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/cb9fe12e-5091-ec55-e542-73c19f8b7483%40iaaras.ru.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Bytecode problem with fxvector inside a macro

2019-05-08 Thread Dmitry Pavlov



On 5/9/19 12:04 AM, Dmitry Pavlov wrote:

Matthew,



The intended error here is "cannot marshal value that is embedded in
compiled code" at `raco make` time, because fxvectors are not supported
as literals. I'll fix the bytecode writer to check for this case.


OK, thank you. What would you recommend, though, to users who want fxvectors (of 
"static" kind) to be generated by macros?
Populating fxvectors in runtime will be a loss of performance, maybe not 
critical, but noticeable.


Ah, I see

#lang racket

(require (for-syntax syntax/parse))
(require  racket/fixnum)

(define-syntax (macro stx)
  (syntax-parse stx
    (({~literal macro})
 (quasisyntax/loc stx
   (begin
 (define v-name (fxvector 5))
 'OK)

(macro)


So I should put fxvector non-literals inside the syntax, and everything will be 
fine.


Best regards,

Dmitry


--
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/14ab0c70-419c-6f27-f88a-97be323ff965%40iaaras.ru.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Bytecode problem with fxvector inside a macro

2019-05-08 Thread Dmitry Pavlov

Matthew,



The intended error here is "cannot marshal value that is embedded in
compiled code" at `raco make` time, because fxvectors are not supported
as literals. I'll fix the bytecode writer to check for this case.


OK, thank you. What would you recommend, though, to users who want fxvectors (of 
"static" kind) to be generated by macros?
Populating fxvectors in runtime will be a loss of performance, maybe not 
critical, but noticeable.

Best regards,

Dmitry


--
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/1f3602a7-8c49-87b1-1d9e-c20c8a415442%40iaaras.ru.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Bytecode problem with fxvector inside a macro

2019-05-08 Thread Dmitry Pavlov

Hello,

I would like to report something that I see as
inconsistent behavior of the bytecode compiler.
The following short program (an artificial minimal
reproducible example) works at first, but fails
after raco make. My OS is Linux.



$ cat one.rkt
#lang racket

(require (for-syntax syntax/parse racket/fixnum))

(define-syntax (macro stx)
  (syntax-parse stx
(({~literal macro})
 (let ((v (fxvector 5)))
   (with-syntax ((v v))
 (quasisyntax/loc stx
   (begin
 (define v-name v)
 'OK)))

(macro)

$ racket one.rkt
'OK

$ raco make one.rkt

$ racket one.rkt
read: bad syntax `#fx'
  in: compiled/one_rkt.zo
  context...:
   read-linklet-or-directory
   read-dispatch
   read
   default-load-handler
   standard-module-name-resolver
   module-path-index-resolve
   [repeats 1 more time]
   module-declared?


$ racket -v
Welcome to Racket v7.2.


Best regards,

Dmitry

--
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/c8d25d54-e69e-ba45-9e78-4bd8366fa51f%40iaaras.ru.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Program aborts except when there are no previously compiled .zo files

2019-04-15 Thread Dmitry Pavlov



It would be good if you can share a link to the code. It is difficult to 
guess where is the problem is with this information. Is there an online 
public repository with the code?


Unfortunately, no. But you are right. I will try and provide an
excerpt on which the crash reproduces.

Best regards,

Dmitry

--
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] Program aborts except when there are no previously compiled .zo files

2019-04-12 Thread Dmitry Pavlov

Hello,

My program demonstrates an unexpected behavior
depending on how I run it.


$ 

$ racket program.rkt


$ raco make program.rkt


$ racket program.rkt
read: bad syntax `#fx'
  in: compiled/subprogram.mylang.zo
  context...:
   "/path/to/myprogram.rkt": [running body]
   temp37_0
   for-loop
   run-module-instance!125
   perform-require!78


Now, in DrRacket:

 on myprogram.rkt works fine if I uncheck the
"populate compiled directories" option.

When I check the "populate compiled directories" option,
or when there are compiled directories previously
populated, DrRacket aborts, printing a message

"about to suspend in atomic mode"

regardless of whether I turn debugging on or off.


The program (require)s another module written
in a different non-sexp #lang with a special fancy
compiler.

Racket 7.2, Linux x64.

Also tried on OS X: same behavior only DrRacket
does not abort, but gives the same '#fx' error instead.


Can I provide any more information to help determining
what is the problem?


Best regards,

Dmitry

--
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] CAM-2019 conference (St. Petersburg, July 22-24)

2019-03-25 Thread Dmitry Pavlov

### About CAM

Computer Assisted Mathematics conference is a forum for scientists
and teachers working in the area of algorithmic mathematics
and interested in promoting of important discrete mathematics
and theoretical informatics ideas into education in technical
universities and schools, including the development of computer
tools for supporting research and productive thinking.

About the conference: http://cam19.ipo.spb.ru/cam19/About_main/go/p

Requirements to submitted papers:
http://cam19.ipo.spb.ru/cam19/Submissions_main/go/p


### Important dates

Abstract submissions due: April 15, 2019

Paper submissions due: May 01, 2019

Conference: July 22-24, 2019


### Venue

Russia, St. Petersburg State Electrotechnical University “LETI”
https://etu.ru/en/university/


### Topics

There will be three sections:

1. Algorithmic Mathematics and Mathematical Modeling
2. Training in algorithmic mathematics and mathematical modeling
3. Computer tools to support teaching and studying of mathematics
   and computer science

The conference topics include but are not restricted to:

- Algorithmic mathematics
- Mathematical modeling
- Discrete analysis
- Control theory
- Theoretical computer science
- Symbolic computations
- Unsolved problems in theoretical and applied computer science
- Software engineering
- Computer aided education
- Software in math education and research
- Training in algorithmic mathematics and mathematical modeling
- Computer tools and teaching technologies to support productive
  thinking in mathematics and computer science


### Program committee

- Oleg Ivanov (chair), St.Petersburg State University, Russia
- Sergei Pozdniakov (co-chair), Saint Petersburg Electrotechnical
  University, Russia
- Nikolai Vasiliev (co-chair), PDMI of Russian Academy of Sciences,
  Russia

- Sergei Abramovich, State University of New York at Potsdam, USA
- Semjon Adlaj, FRCIС of Russian Academy of Sciences, Russia
- Alkiviadis Akritas, University of Thessaly, Greece
- Vladimir Dubrovsky, Moscow State University, Russia
- Viktor Freiman, Université de Moncton, Canada
- Dima Grigoriev, CNRS, Lille, France
- Juraj Hromkovic, ETH Zurich, Switzerland
- Mirjana Ivanovic, University of Novi Sad, Serbia
- Eugenijus Kurilovas, Vilnius Gediminas Technical University, Lithuania
- Yuri Matiyasevich, PDMI of Russian Academy of Sciences, Russia
- Christian Mercat, Claude Bernard University Lyon, France
- Dmitry Pavlov, IAA of Russian Academy of Sciences, Russia
- Michael Weigend, University of Münster, Germany
- Tatiana Mylläri, St.George’s University, Grenada, West Indies


### Registration and abstract submission

Abstract submission is done via EasyChair:
https://easychair.org/conferences/?conf=cam20190

(Paper submission has not opened yet.)


### Publications

Accepted papers will be published in the journal
“Computer Tools in Education” (CTE) and also in a new journal
“Computer Assisted Mathematics” which will open in 2019 and will
be the successor to CTE.
http://cte.eltech.ru/ojs/index.php/kio/about


### Fees

- Full: 250 €
- Student (Doctoral/PhD/graduate student): 100 €
- Student (Bachelors/Masters/undergraduate student): 75 €
- Accompanying person: 100 €
- Full for citizens of Russia and the CIS: 100 €

--
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] net/url: Can not download a file over HTTPS

2019-01-24 Thread Dmitry Pavlov



An additional reason to do it with Racket's HTTP libraries is so that 
one bot someday going crazy doesn't make a devops/sysadmin see that it's 
Racket, and think unhappy thoughts about Racket. :)


Agreed.


Best regards,

Dmitry

--
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] net/url: Can not download a file over HTTPS

2019-01-24 Thread Dmitry Pavlov

Neil,

Thank you so much, I did not know that I can play with
the header so easily in get-pure-port.

It turned out that the server expects "Accept:" field
in the request (but does not care much about its value).

So the following code works

#lang racket

(require net/url)

(let* ((url 
"https://datacenter.iers.org/data/latestVersion/9_FINALS.ALL_IAU2000_V2013_019.txt;)

   (p (get-pure-port (string->url url) '("Accept: */*"
  (for ((l (in-lines p)))
(displayln l)))


And my pipeline is fixed. Great!

Best regards,

Dmitry

--
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] net/url: Can not download a file over HTTPS

2019-01-24 Thread Dmitry Pavlov

Hello,

My workflow broke because of some mess going on with SSL certificates
or something. I do not understand what is going on and how to fix it.
Could please anybody give an idea?

Here is a link:
https://datacenter.iers.org/data/latestVersion/9_FINALS.ALL_IAU2000_V2013_019.txt

It opens in browser. It downloads via wget. In Racket, it does not.

Here is the simplified version of the code:

#lang racket/base

(require net/url net/url-connect openssl)

;; it used to work even without this line
;; now it does not work with or without it
(current-https-protocol (ssl-secure-client-context))

(let* ((url 
"https://datacenter.iers.org/data/latestVersion/9_FINALS.ALL_IAU2000_V2013_019.txt;)

   (p (get-pure-port (string->url url
  (for ((l (in-lines p)))
(displayln l)))


I get the following HTML code in return:




403 Forbidden

Forbidden
You don't have permission to access 
/data/latestVersion/9_FINALS.ALL_IAU2000_V2013_019.txt

on this server.



I just tried this with Racket 6.12 and Racket 7.1.
In both cases, the OS was Debian Linux.


Best regards,

Dmitry

--
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: plot library: legend outside plot?

2018-11-11 Thread Dmitry Pavlov

Alex,

Thank you! I did not know about plot-pict.

Best regards,

Dmitry

On 11/11/18 2:45 AM, Alex Harsanyi wrote:


If you are willing to do some programming, you can write your own function to 
create the legend, as below:

    #lang racket
    (require plot pict racket/draw)

    ;; I could not find how to draw styled lines in pict, so I wrote my own
    ;; function
    (define (hline1 w h color style)
  (define (draw dc x y)
    (define pen (send the-pen-list find-or-create-pen color h style))
    (define old-pen (send dc get-pen))
    (send dc set-pen pen)
    (send dc draw-line x (+ y (/ h 2)) (+ x w) (+ y (/ h 2)))
    (send dc set-pen old-pen))
  (dc draw w h))

    (define (legend)
  (define picts
    (list
 (hline1 30 2 "red" 'long-dash) (text "sin")
 (hline1 30 4 "blue" 'short-dash) (text "cos")))
  (frame
   (inset
    (vc-append
 15
 (text "Legend" 'default 14)
 (table 2 picts cc-superimpose cc-superimpose 10 10))
    5)))

    (define (the-plot)
  (plot-pict (list
   (function sin #:color "red" #:width 2 #:style 'long-dash)
   (function cos #:color "blue" #:width 4 #:style 'short-dash))
  #:x-min -5 #:x-max 5))

    (ht-append (legend) (the-plot))

Which produces:

loutside.png

You can than write the pict to a bitmap using `pict->bitmap`.  The code above 
will not produce interactive plot snips -- it is possible to do that as well, in 
my own application I have a floating legend that I can drag around the plot so I 
can see what is underneath it, but implementing that is a bit more complex.

The obvious disadvantage of this code is that you have to manually manage the 
legend entries or write higher level wrappers for the plot functions to 
generate both legend entries and plot renderers.  The big advantage is that you 
can style the legend however you want.

Best Regards,
Alex.

On Friday, November 9, 2018 at 9:16:48 PM UTC+8, Alex Harsanyi wrote:


It is not currently possible to draw the legend outside the plot area.  The 
code that draws the legend is at the link below, however, this code assumes 
that the position will be inside the plot area and will not reserve extra space 
outside this area:


https://github.com/racket/plot/blob/8dcfd7745e2595b8d517fd8cd7c59510efab84a9/plot-lib/plot/private/common/plot-device.rkt#L587
 
<https://github.com/racket/plot/blob/8dcfd7745e2595b8d517fd8cd7c59510efab84a9/plot-lib/plot/private/common/plot-device.rkt#L587>

    Alex.

On Thursday, November 8, 2018 at 11:18:14 PM UTC+8, Dmitry Pavlov wrote:

Hello,

Is it possible to render a plot with the legend outside the plotting
area, like gnuplot does with "set key outside" option?

I see only (plot-legend-anchor) parameter for placement of the legend in
different places inside the plot area.

Best regards,

Dmitry


--
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 
<mailto: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] plot library: legend outside plot?

2018-11-08 Thread Dmitry Pavlov

Hello,

Is it possible to render a plot with the legend outside the plotting 
area, like gnuplot does with "set key outside" option?


I see only (plot-legend-anchor) parameter for placement of the legend in 
different places inside the plot area.


Best regards,

Dmitry


--
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] plan for the upcoming v7.0 release

2018-05-27 Thread Dmitry Pavlov



On 05/27/2018 03:10 PM, Matthew Flatt wrote:

Hi Dmitry,

At Sun, 27 May 2018 14:21:27 +0300, Dmitry Pavlov wrote:

We do not expect Racket users to see a big difference between Racket
v6.12 and Racket v7.0.


I once saw in some text file that extflonums will not make it to Racket on
Chez.
Will they be available in Racket 7.0?


Yes. Although we hope to replace the current runtime system with Chez
Scheme for the main distribution, the current runtime system will stay
supported as an alternative, and it will always support extflonums.


OK, thanks.

What will happen to the performance of expander, though?
IIUC, the present C expander will be gone in Racket 7 and replaced
with a new expander written in Racket. While Chez runtime
users will enjoy the Racket performance boost that will
compensate for the change of expander from C to Racket,
the users that opt for the old runtime will notice a slowdown
of expander because it is no longer managed by C but by
old (slower) Racket. Is that correct?

Best regards,

Dmitry

--
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] Is it possible to pass syntax information from bottom up?

2018-04-18 Thread Dmitry Pavlov

Matthias,

Thank you for the reference. It turns out that I should have looked into
local-expand rather than expand-syntax.

Out of the two options (inserting type info into syntax or keeping
it in the syntax-property) I chose the latter, because I like
thinking of them as properties rather than syntax.


Stephen, thank you. I actually wrote a similar program myself
before I received yours. It is similar. I put it here for
the record. One difference is that it uses syntax-track-origin
to handle nested (this).




#lang racket/base

(require racket/format
 (for-syntax syntax/parse)
 (for-syntax racket/base))

(define-syntax (print stx)
  (syntax-parse stx
(((~literal print) expr)
 (with-syntax ((expanded (local-expand #'expr 'expression '(
   (case (syntax-property #'expanded 'number-type)
 ((float)
  (syntax/loc stx
(displayln (~r expanded #:notation 'positional #:precision 
'(= 2)

 ((integer)
  (syntax/loc stx
(printf "~a\n" expanded

(define-syntax (this stx)
  (syntax-parse stx
(((~literal this) (expr ...))
 (with-syntax ((expanded (local-expand #'(expr ...) 'expression '(
   (syntax-track-origin (syntax/loc stx expanded) (car (syntax-e 
#'(expr ...))) #'this)))

(((~literal this) datum)
 (if (exact? (syntax->datum #'datum))
 (begin
   (printf "we know at compile time that it is an integer\n")
   (syntax-property (syntax/loc stx datum) 'number-type 'integer))
 (begin
   (printf "we know at compile time that it is a float\n")
   (syntax-property (syntax/loc stx datum) 'number-type 
'float))


(print (this (this (this 123
(print (this (this (this 456.0


Regards,

Dmitry






On 18.04.2018 16:39, Matthias Felleisen wrote:


You want to look at Stephen's Turnstile, a DSL for making typed DSLs and 
macros. Like all type systems, this is exactly what it does.

Here is the link to the paper:

  https://www2.ccs.neu.edu/racket/pubs/#popl17-ckg

It obscures what you need, which is a combination of local-expand, syntax-parse 
and its various hooks. The rough idea is to locally expand a given phrase and 
to expand in such a way that macros return two pieces of information: the 
expanded syntax and the additional property. You can try to encode this with

#'(begin expanded-code property)

or just use a syntax-property, whatever fits best. When the local-expand 
returns, take apart the macro and re-do the same thing.

Details in the implementation.

You may also wish to look at the implementation of Alexis’ Hackett.







On Apr 18, 2018, at 8:40 AM, Dmitry Pavlov <dpav...@iaaras.ru> wrote:

Hello,

I am looking for an advice on how to write a macro that is aware of the information 
extracted from syntax objects from another macro that is called "inside" the 
first one. For instance, let it be the (this) macro that detects if its argument is an 
integer or float, and let it be the (print) macro that should emit the according printing 
command -- at compile time.

Here is a stub (not working) to show what I am trying to achieve:

#lang racket/base

(require racket/format
  (for-syntax syntax/parse)
  (for-syntax racket/base))

(define-syntax (print stx)
   (syntax-parse stx
 (((~literal print) expr)
  (if #t ;; need some condition here that knows whether expr is an integer 
or a float
  (syntax/loc stx
(displayln (~r expr #:notation 'positional #:precision '(= 2
  (syntax/loc stx
(printf "~a\n" expr))

(define-syntax (this stx)
   (syntax-parse stx
 (((~literal this) (expr ...))
  (syntax/loc stx (expr ...))
  )
 (((~literal this) datum)
  (if (exact? (syntax->datum #'datum))
(printf "we know at compile time that is is an integer\n")
(printf "we know at compile time that is is a float\n"))
  (syntax/loc stx datum


(print (this (this (this 123
(print (this (this (this 456.0


How do I achieve that (print) knows which number is in (this) down there?
I thought about (syntax-property), but it does not work, either because I am 
misapplying it, or because of the way the syntax expander works.

I also tried to (expand-syntax) to get the syntax expander work bottom-up, but 
eventually decided that it can not work too, or I do not understand how it 
should work.

The other option that I see is "manual" processing of the whole syntax tree 
after the (syntax-parse) did its job. But it seems a bit extra for the task. Is it the 
only way?

Best regards,

Dmitry


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

[racket-users] Is it possible to pass syntax information from bottom up?

2018-04-18 Thread Dmitry Pavlov

Hello,

I am looking for an advice on how to write a macro that is aware of the 
information extracted from syntax objects from another macro that is 
called "inside" the first one. For instance, let it be the (this) macro 
that detects if its argument is an integer or float, and let it be the 
(print) macro that should emit the according printing command -- at 
compile time.


Here is a stub (not working) to show what I am trying to achieve:

#lang racket/base

(require racket/format
 (for-syntax syntax/parse)
 (for-syntax racket/base))

(define-syntax (print stx)
  (syntax-parse stx
    (((~literal print) expr)
 (if #t ;; need some condition here that knows whether expr is an 
integer or a float

 (syntax/loc stx
   (displayln (~r expr #:notation 'positional #:precision '(= 2
 (syntax/loc stx
   (printf "~a\n" expr))

(define-syntax (this stx)
  (syntax-parse stx
    (((~literal this) (expr ...))
 (syntax/loc stx (expr ...))
 )
    (((~literal this) datum)
 (if (exact? (syntax->datum #'datum))
   (printf "we know at compile time that is is an integer\n")
   (printf "we know at compile time that is is a float\n"))
 (syntax/loc stx datum


(print (this (this (this 123
(print (this (this (this 456.0


How do I achieve that (print) knows which number is in (this) down there?
I thought about (syntax-property), but it does not work, either because 
I am misapplying it, or because of the way the syntax expander works.


I also tried to (expand-syntax) to get the syntax expander work 
bottom-up, but eventually decided that it can not work too, or I do not 
understand how it should work.


The other option that I see is "manual" processing of the whole syntax 
tree after the (syntax-parse) did its job. But it seems a bit extra for 
the task. Is it the only way?


Best regards,

Dmitry


--
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 access lexical context from macro?

2018-04-16 Thread Dmitry Pavlov

Oh, syntax-parameter-value has helped.

#lang racket

(require (for-syntax syntax/parse syntax/transformer)
 racket/stxparam)

(define-syntax-parameter my-info '())

(define-syntax (access stx)
  (syntax-parse stx
    ((_)
 (printf "my-info = ~v\n" (syntax-parameter-value #'my-info))
 #''ok)))

(define-syntax (save stx)
  (syntax-parse stx
    [(_ body:expr)
 #'(syntax-parameterize ((my-info
  (cons 'new-info (syntax-parameter-value 
#'my-info

 body)]))

(save
 (begin
   (save
    (access


it prints

my-info = '(new-info new-info)
'ok


Seems to be exactly what I was looking for. Thanks for help!


Best regards,

Dmitry

--
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 access lexical context from macro?

2018-04-16 Thread Dmitry Pavlov


You can "pass" information from one macro to another by binding 
information to an identifier defined to be a syntax parameter that 
both macros have in scope. You would need to functionally update its 
value for each rebinding. Its value would be retrievable with 
syntax-local-value.


Like this, am I close? I tried to make a shortest possible example.
But it does not work as I expected: it prints "my-info = 
#" rather than '(new-info).



#lang racket

(require (for-syntax syntax/parse syntax/transformer)
 racket/stxparam)

(define-syntax-parameter my-info '())

(define-syntax (access stx)
  (syntax-parse stx
    ((_)
 (printf "my-info = ~v\n" (syntax-local-value #'my-info))
 #''ok)))

(define-syntax (save stx)
  (syntax-parse stx
    [(_ body:expr)
 #'(syntax-parameterize ((my-info
  (cons 'new-info (syntax-local-value 
#'my-info

 body)]))

(save
 (access))


Best regards,

Dmitry

--
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 access lexical context from macro?

2018-04-16 Thread Dmitry Pavlov

Amalie,

Thank you, this is impressive and helpful. I did not know about 
syntax-local-value (I also am not certain that I know it now good enough).


However, I did not mean to use the (my-let)'s "definition" of x to pass 
information to (access). (Also, can (access y) fail in a customizable 
way?) I was wondering if there is a way to just pass any information 
(list of variables, which can be empty, or whatever else) from (my-let) 
to (access).


Best regards,

Dmitry


On 17.04.2018 1:18, Dionna Amalie Glaze wrote:
syntax-local-value is likely what you'll want to use here. You can 
bind your x to a compile-time value that you can access with 
syntax-local-value. You can even make that value a struct with 
#:procedure prop:procedure and have its procedure be a syntax 
transformer (so it can expand into something meaningful outside its 
use by access).


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

(begin-for-syntax
  (struct communicate (syntax value) #:prefab))

(define-syntax (access stx)
  (syntax-parse stx
    [(_ x:id)
     #:fail-unless (communicate? (syntax-local-value #'x))
     (format "Expected ~a to be bound by my-let" (syntax-e #'x))
     (define slv (syntax-local-value #'x))
     #`(list #,(communicate-syntax slv) 'has-tree-nodes 
'#,(communicate-value slv))]))

(define-syntax (my-let stx)
  (syntax-parse stx
    [(_ ([x:id e:expr] ...) body:expr)
     #'(let-syntax ([x (communicate #'e
 (length (flatten (syntax->datum #'e] ...)
   body)]))
(my-let ([x '(a b ((c d) 4) (5 9))])
  (access x))

;=>

'((a b ((c d) 4) (5 9)) has-tree-nodes 8)

(the answer is 8 and not 7 because it's counting the 'quote in the syntax)

On Mon, Apr 16, 2018 at 2:16 PM Dmitry Pavlov <dpav...@iaaras.ru 
<mailto:dpav...@iaaras.ru>> wrote:


Hello,

I would like to write two seemingly simple macros and I found
no way to do it.

(my-let ((x 2))
   (begin
     (begin
       (begin
         (access x)
         (access y)

I would like the (access) macro to know at compile (expansion)
time that x is up there in (my-let) macro and y is not.

I tried the following:

- save information about 'x during (my-let) expansion
   in a parameter (present in expander but not in
   expanded code) and check that parameter in (access).
   This does not seem to work, probably because of
   the way expansion works.

- attach information as a property to syntax object
   generated by (my-let), then bring it all the way down
   (that requires redefining begin) and get it back
   from syntax object in (access). That works, but is
   a pain.

- explicitly call (expand-syntax) for (my-let)'s body
   in (my-let)'s expansion. Does not work because (access)
   is not yet available at that point.

- find and read "Macros that work together" my Flatt et al.
   Well, I did try to find what I need, until the code
   has switched from Racket to some other fancy language
   and then I am stuck.


Any advice please?

Best regards,

Dmitry

-- 
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
<mailto:racket-users%2bunsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout.



--
-Dionna Glaze, PhD (she/her)


--
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] How to access lexical context from macro?

2018-04-16 Thread Dmitry Pavlov

Hello,

I would like to write two seemingly simple macros and I found
no way to do it.

(my-let ((x 2))
  (begin
(begin
  (begin
(access x)
(access y)

I would like the (access) macro to know at compile (expansion)
time that x is up there in (my-let) macro and y is not.

I tried the following:

- save information about 'x during (my-let) expansion
  in a parameter (present in expander but not in
  expanded code) and check that parameter in (access).
  This does not seem to work, probably because of
  the way expansion works.

- attach information as a property to syntax object
  generated by (my-let), then bring it all the way down
  (that requires redefining begin) and get it back
  from syntax object in (access). That works, but is
  a pain.

- explicitly call (expand-syntax) for (my-let)'s body
  in (my-let)'s expansion. Does not work because (access)
  is not yet available at that point.

- find and read "Macros that work together" my Flatt et al.
  Well, I did try to find what I need, until the code
  has switched from Racket to some other fancy language
  and then I am stuck.


Any advice please?

Best regards,

Dmitry

--
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] Windows Foreign Libraries

2018-03-23 Thread Dmitry Pavlov



On 03/23/2018 03:58 PM, silverfire...@gmail.com wrote:

Really silly question but I was using the rsvg package with racket/gui on Linux 
and everything was working fine.   I moved the code over to windows to try it 
out (after installing the rsvg package there) and it's complaining that 
librsvg-2.2.dll is missing.   I've now tried two separate .dll files in my code 
directory (one that was from the official gnome ftp) and racket throws an error 
that ($1 is not a valid Win32 application) when trying to call (ffi-lib) on it.


Two points:

First, you may want to modify config.rktd in the Racket distribution directory
so that (lib-search-dirs) contains the directory where your dll is located.
This is not needed if you have it in a system directory or load it by full path.

Second, your dll may refuse to load because some of its dependencies
are missing. You may use the freeware Dependency Walker (depends.exe)
to find out what is missing.


Regards,

Dmitry

--
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] "Immobile" lambdas for FFI

2018-03-15 Thread Dmitry Pavlov

Matthew,

I agree with John on this one.

In case you decide to release the files, you may want to correct
the comment in callback.rkt: it has (define b #f) and (define b null)
where I believe you mean (define b (box #f)) and (define b (box null)),
respectively. Also, among listed options for #:keep,
two are marked as defaults.

Best regards,

Dmitry

On 03/15/2018 11:48 PM, John Clements wrote:




On Mar 14, 2018, at 6:22 PM, Matthew Flatt  wrote:




Would it make sense to add these two examples to the documentation? Perhaps 
just as links to github gists? Apologies if they’re already there; I took a 
quick look and didn’t see them.

(I suggest this selfishly, because my ‘rsound’ package is somewhat “crashy” on 
windows.)

John





--
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] "Immobile" lambdas for FFI

2018-03-15 Thread Dmitry Pavlov

Matthew,

On 03/15/2018 04:22 AM, Matthew Flatt wrote:

At Wed, 14 Mar 2018 21:56:05 +0300, Dmitry Pavlov wrote:

I suspect that "my-callback" or something linked to it are moved
in memory by the garbage collector, and the pointer kept by
the C library is no longer valid. In the first simpler
case, that does not happen because it sets and uses the
callback in the single FFI call, right?


Callbacks are a kind of special case, and you don't have to worry about
them moving. (I'll add that to the documentation.) You only have to
worry about keeping them from being GCed.


Oh, OK. I was disoriented by the manual which has "callbacks" and
"moved in memory" in the same sentence.

Thank you very much for the incredibly detailed example program!
I actually had a multiple (double) registration of the callback
function, but the second registration was turned off and
my program still crashed.


If the issue isn't about multiple registrations, then my only guess is
that the box you're using doesn't remain reachable. 


In fact, it was a silly mistake: I passed #:keep to the wrong
_fun -- in terms of the example program, in set-callback
instead of _callback.

Once I fixed that, everything got back on track.



Best regards,

Dmitry

--
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] (dynamic-require) performance problem

2018-02-12 Thread Dmitry Pavlov

Matthew,


I can imagine a problem where the "language implementation" is in the
reader, in which case it wouldn't get run when loading from bytecode,
but that doesn't explain why `racket ` works --- unless the
initialization is also triggered by a `main` or `configure-runtime`
submodule, which would be run by `racket `.


You are right, it is in the configure-runtime. Here is the source of
my slon/lang/configure-runtime.rkt file. It has not changed since 2011
when I wrote it. It probably reflects my incompetence in implementing
languages, but anyway:



[...]


Oh, I see that the upstream Racklog source [1] has changed and no
longer uses the odd-read/even-read hack. I will borrow the
implementation from there, again, effectively removing the parser
dependency in configure-runtime,and see how it goes.


No, the Racklog still does use parser and compiler in the configure-runtime.
And so am I.

I have addressed the issue by (require)-ing the needed module directly in the
language runtime, too, so my hash table gets filled up even if the reader has 
not acted. Thank you!

Best regards,

Dmitry


--
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] (dynamic-require) performance problem

2018-02-12 Thread Dmitry Pavlov



   Does the port `p` contain
the source text for , or does it contain the bytecode from
the ".zo" file created by `raco make ?

In this dedicated test, just the source text of  and nothing else.


I think this is the main cause of the performance difference, but just
to make sure, does

   raco make ; rm ; time racket 

take ~4 seconds, where  is in a "compiled" dierctory
relative to ?


Yes, it does! So the issue is just that  itself takes ~3 seconds
to compile. Having other sources consumed even more time to compile,
I did not figure that. Thank you.


If so, then the solution could be to use `require-input-port` on a port
that has bytecode for , instead of the program source.


I just tried that, and... got the hash table error that is the same as with
(dynamic-require  #f).



I just tried to check what I get with (dynamic-require  #f) instead
of require-input-port.
In turns out that I get a "hash-ref: no value found for key" error originating
from  implementation.
It indicates that something went not as is was supposed to go in the dependent
modules loading.
There is a certain module (I will call it "functions") that, when loaded,
fills up the hash table in another module ("functions-table"), and this hash
table is being used by the language implementation. Of course, the language
implementation does (require) "functions-table" and then "functions".
Something went wrong with that scheme when I used the (dynamic-require
 #f) approach.
It never went that way when I used (require-input-port) or "racket
".


I'm stumped here.

I can imagine a problem where the "language implementation" is in the
reader, in which case it wouldn't get run when loading from bytecode,
but that doesn't explain why `racket ` works --- unless the
initialization is also triggered by a `main` or `configure-runtime`
submodule, which would be run by `racket `.


You are right, it is in the configure-runtime. Here is the source of
my slon/lang/configure-runtime.rkt file. It has not changed since 2011
when I wrote it. It probably reflects my incompetence in implementing
languages, but anyway:



#lang racket/base

(require slon/slon-parser)
(provide configure)

(define (configure data)
  (current-read-interaction even-read))

;; Taken from Datalog source, which says "This is almost certainly wrong."
;; So we are going to be wrong too.
(define (even-read source-name input-port)
  (begin0
(slon-read-syntax source-name input-port)
(current-read-interaction odd-read)))

(define (odd-read src ip)
  (current-read-interaction even-read)
  eof)



slon/slon-parser.rkt requires slon/slon-compiler.rkt, which, in turn,
requires those "functions" and "functions-table" modules that make
the error happen.

So, how bad is this all, really? :)

Oh, I see that the upstream Racklog source [1] has changed and no
longer uses the odd-read/even-read hack. I will borrow the
implementation from there, again, effectively removing the parser
dependency in configure-runtime,and see how it goes.


Best regards,

Dmitry

[1] https://github.com/racket/racklog/blob/master/lang/configure-runtime.rkt

--
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] (dynamic-require) performance problem

2018-02-12 Thread Dmitry Pavlov

Matthew,


I'm not clear on why you're using `require-input-port` here instead of
`dyanmic-require` with 's path.

Originally, I needed it to prepend "#lang " to the source because I did 
not have it in the file.
That requirement is not so strict now and I will be able to lift it if it is 
critical for performance.

I just tried to check what I get with (dynamic-require  #f) instead 
of require-input-port.
In turns out that I get a "hash-ref: no value found for key" error originating from 
 implementation.
It indicates that something went not as is was supposed to go in the dependent 
modules loading.
There is a certain module (I will call it "functions") that, when loaded, fills up the hash table in another 
module ("functions-table"), and this hash table is being used by the language implementation. Of course, the 
language implementation does (require) "functions-table" and then "functions".
Something went wrong with that scheme when I used the (dynamic-require 
 #f) approach.
It never went that way when I used (require-input-port) or "racket ".
Should I provide more details? Does the dynamic-require vs require-input-port 
issue matters for performance?


  Does the port `p` contain
the source text for , or does it contain the bytecode from
the ".zo" file created by `raco make ?

In this dedicated test, just the source text of  and nothing else.

Best regards,

Dmitry

--
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] (dynamic-require) performance problem

2018-02-12 Thread Dmitry Pavlov

Hello,

I have a performance problem with loading a Racket program dynamically.

I measure the time taken to execute a program in two different ways:

1. raco make ; time racket 

2. raco make my-runner.rkt; raco make ; time racket my-runner.rkt 


In the first case, execution takes ~1 second, in the second case ~4 seconds.
(The time to run 'raco make' is not measured.)
I checked Racket 6.10 and Racket 6.11 on Linux.

Some additional observations (very basic, since I know little about Racket
module loading mechanism):

- Delay does not go anywhere if I run  second time within the same
  my-runner.rkt instance.

- It I omit 'raco make' and remove all the 'compiled' folders from my source
  code tree, running the program takes ~18 seconds in both cases, so there is
  no performance difference in that case.


 is written in a non-Racket #lang with its own reader.
To load it dynamically in my-runner.rkt, I use the following function
kindly provided by Matthew Flatt a few years ago on this mailing list:

(define (require-input-port p [name (gensym)])
  (define module-name (make-resolved-module-path name))
  (parameterize ([current-module-declare-name module-name])
(eval-syntax (check-module-form ; ensures that `module` is bound
  (with-module-reading-parameterization
   (lambda ()
 (read-syntax (object-name p) p)))
  'ignored
  #f)))
  (dynamic-require module-name #f))

Other than performance, it works great.
Is there a way to make it as fast as the "static" command-line runner?
Many thanks in advance.


Regards,

Dmitry

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

2018-02-05 Thread Dmitry Pavlov
Deren,

In addition to what Matthew has said, I guess you need to have a 'main' module 
in your language, and provide it to raco exe, too. It can be a dummy module or 
not. The requirement of such a module is unclear to me, but it exists.

Here is my working script to pack a standalone interpreter of a language 'slon' 
on Windows:

raco exe -o slon-racket ++lib slon/slon-language ++lib slon/lang/reader ++lib 
slon/main slon-interpreter.rkt
raco distribute slon-racket slon-racket.exe 

Regards,

Dmitry

On February 1, 2018 8:53:50 PM EET, Deren Dohoda  wrote:
>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.

-- 
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] Using ffi/unsafe/alloc

2018-01-24 Thread Dmitry Pavlov

Konrad,

I would create a wrapper like this:

(define-fooapi make-foo
 (_fun (foo : (_ptr o _foo)
    -> (r : _int)
    -> (if r (begin (register-finalizer-and-custodian-shutdown foo 
destroy-foo) foo)
    (error "can not make foo")))


Regards,

Dmitry

On 01/24/2018 10:47 PM, Konrad Hinsen wrote:

Hi everyone,

I am working on an FFI which overall progresses well - the Racket FFI library 
is really a very nice tool to have.

The one problem I couldn't solve yet is handling resource allocation. My use 
case is very similar to what allocator/deallocator are meant for, except that 
the allocated object is not the return value of any function, and therefore I 
cannot use allocator.

I have an API like

   int make_foo(foo** new_foo);
   int destroy_foo(foo* a_foo);

so my FFI definitions look like

  (define _foo (_cpointer 'foo))

  (define-fooapi make-foo
 (_fun (foo : (_ptr o _foo)
    -> (r : _int)
    -> (values r foo))

  (define-fooapi destroy-foo
 (_fun _foo -> _void))

Given that make-foo returns two values, I cannot use #:wrap to make it an 
allocator.

Since the C API I am wrapping is pretty standard, I suspect others have had 
this problem before. Any suggestions?

Thanks in advance,
  Konrad.



--
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 wiki page ‘friends of Racket’

2017-10-31 Thread Dmitry Pavlov


I have added some Racket-related information about the Institute of 
Applied Astronomy I work in.


Stephen or Racket-devs: feel free to edit it if needed.


Regards,

Dmitry


On 28.10.2017 12:56, Stephen De Gabrielle wrote:

I created a new wiki page
https://github.com/racket/racket/wiki/Friends-of-Racket
 (yes, I got the idea from rust-lang)

I did it because it is a question that keeps turning up.

Racket-devs: If it is not appropriate for the wiki please delete it.

Kind regards,
Stephen




--
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: New wiki page ‘friends of Racket’

2017-10-31 Thread Dmitry Pavlov




John Carmack uses Racket as script language in Oculus platform.

Not anymore: https://twitter.com/ID_AA_Carmack/status/739289907038801921

Regards,

Dmitry

--
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] can't (require table-panel) today

2017-10-13 Thread Dmitry Pavlov




#lang racket/gui
(require table-panel)

leads to:

standard-module-name-resolver: collection not found

Have you tried raco pkg install table-panel?

Best regards,

Dmitry

--
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] Spacemacs Light & Dark Color Schemes for DrRacket

2017-08-31 Thread Dmitry Pavlov





However, I've now ported the Spacemacs light and dark themes for Emacs to 
DrRacket color schemes.

https://github.com/tuirgin/drracket-spacemacs-schemes

Very nice and useful. Thank you very much!

Regards,

Dmitry

--
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: tables and figures with captions and numbering?

2017-07-07 Thread Dmitry Pavlov

Ben, Georges,

Many thanks for your input.
I checked out the example of a figure from the Scribble manual:

#lang scribble/manual
@(require scriblib/figure)

@figure["straw" @elem{A straw}]{@image["straw.png"]}

Reference to @(figure-ref "straw").


The figure itself successfully converts to LaTeX and HTML, but strangely not 
Markdown.
The reference is no longer a reference-by-name in LaTeX or Markdown output, 
though those formats provide referencing by labels.

It is good to know that a low-level referencing mechanism is provided in 
Scribble, though.

Best regards,

Dmitry

--
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] Scribble: tables and figures with captions and numbering?

2017-07-06 Thread Dmitry Pavlov

Hello,

I have zero experience with Scribble, and today I have been considering using 
it to document a program.
Previously, I have been using LaTeX, Markdown, and Word.

One of the first questions that comes to mind is: can I assign captions to 
tables (rendered above the table) and figures (rendered below the figure)?
Can I attach numbers to them, like "Table 1. " 
and reference that table by number in the text?

I understand that since Scribble is programmable, I can work out my own procedures for 
rendering and numbering, but I am looking for a more "Scribble-native" way so 
that the connection between an object and its caption will not be lost after conversion 
to Markdown or LaTeX.

Also, can I number the scribble-math equations with a number rendered to the 
right from the equation, and reference them, too?

Best regards,

Dmitry

P.S. If I am wanting something that is counter-Racket 
counter-literate-programming old-fashioned boring bureaucracy, please feel free 
to let me know.

--
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] using a created language in the repl

2017-05-25 Thread Dmitry Pavlov

Vityou,

I will give you an example though I myself sometimes doubt that I did it in the 
right way.

Anyway, here is what I did when I had exactly the same problem:

- redefine and reexport #% top-interaction
- provide #:language-info to the DrRacket's REPL (I am not sure if racket's 
REPL needs it too, but doing it will not hurt). The provided call should 
respond to 'configure-runtime key
- the 'configure-runtime should trigger a setting of (current-read-interaction) 
parameter.
- at the end of the implementation of (current-read-interaction), it should set 
another (current-read-interaction) that just returns EOF -- and then sets the 
original (current-read-interaction) back, so it is kind of a loop.

The example (made long ago) is available at: https://github.com/kugelblitz/calc

Relevant parts:
/language.rkt (see top-interaction)
/lang/reader.rkt (reference to lang-info)
/lang/lang-info.rkt (calling of "configure runtime" handler)
/lang/configure-runtime.rkt (the handler itself)

Hope this helps.

Dmitry



On 05/18/2017 06:45 AM, Vityou wrote:

I did reprovide all of the #%... forms from racket, and the repl works with 
base.rkt, it's when I have a reader that the repl doesn't work.



--
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: "Link: bad variable linkage" when trying to work through tutorial

2017-05-14 Thread Dmitry Pavlov

Onno,



I tried deleting all ZO files in the Racket tree, but that broke my Racket 
installation.

Sorry, I did not mean to suggest deleting all .zo files in the Racket tree. I 
should have been more specific. What I meant was the .zo files for your 
programs.

Best regards,

Dmitry

--
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] "Link: bad variable linkage" when trying to work through tutorial

2017-05-13 Thread Dmitry Pavlov
Onno,

That happens when the .zo files produced by plain command-line racket conflict 
with ones that come from DrRacket. Or the other way around, I am not sure. Or 
something else related to .zo files that are no longer valid for some reason. 
Anyway, try removing the 'compiled' directories from your source tree and 
restarting.

Regards,

Dmitry

On May 14, 2017 12:19:22 AM EET, onn...@gmail.com wrote:
>Hi all,
>
>While working through the first bits of the HtDP2e book, in DrRacket
>6.9 on Mac, I get the following error whenever I try to run any program
>in the "Definitions" window that contains (require 2htdp/universe):
>
>link: bad variable linkage;
>reference to a variable that is not a procedure or structure-type
>constant across all instantiations
>  reference phase level: 0
>variable module: "/Applications/Racket
>v6.9/share/pkgs/string-constants-lib/string-constants/string-constant.rkt"
>  variable phase: 0
>reference in module: "/Applications/Racket
>v6.9/share/pkgs/htdp-lib/2htdp/private/world.rkt"
>
>Googling the error didn't help me out, and I'm afraid I'm too much of a
>noob right now to understand what's going on. What's more, I'm really
>sure this worked fine a few days ago. Restarting DrRacket doesn't help
>either.
>
>Any suggestions would be most welcome! Thanks in advance :-)
>
>Best regards,
>
>
>Onno
>
>-- 
>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] Announcing Leibniz, a new language in the Racket universe

2017-04-26 Thread Dmitry Pavlov

Konrad,

Sorry I am a bit late to the party.
You may remember me from this topic: 
https://groups.google.com/forum/#!topic/racket-users/E6utg2Pv5hA
where I looked for a scientific language and a tool for code generation.

Leibniz seems to be very general. Is generation of (C or other) code from 
Leibniz one of the goals of the project?

Regarding the plans of future development of Leibniz, my humble opinion is that the 
"express algorithms" part is very important for, um, production use. Also, 
vectors and matrices. As an example, I would love to see (or be able to write) an 
equation for gravitational N-body problem (with arbitrary N) in Leibniz.

Best regards,

Dmitry

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

2016-12-22 Thread Dmitry Pavlov



On 12/21/2016 11:33 PM, Jos Koot wrote:


Or up to 60, 60 even nowadays being a commonly used radix in time notation.


FWIW, the radix of the time notation does not seem that simple to me.
I would rather say it is a combined notation.

base-10 (days), base-60 (up to 24 hours+minutes+seconds), base-10 (fractions of 
a second)

or

base-60 (up to 360 degrees+minutes+seconds), base-10 (fractions of a second)




Why restricting it to 36?


I guess that the original poster implied 10 digits + 26 Latin letters for 
notation.



Best regards,

Dmitry

--
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] errortrace requires 10x time and memory for the program to compile

2016-12-12 Thread Dmitry Pavlov

Matthew,

On 12/10/2016 06:22 PM, Matthew Flatt wrote:

At Mon, 5 Dec 2016 10:19:03 -0700, Matthew Flatt wrote:

There's a pending issue of making sure that `for` loops or other things
are not needlessly instrumented, since they're only part of the
expansion instead of the original code. We haven't gotten back to that,
but I bet it would help with your program.


We got back to that over the past week, so you could try a snapshot
version of Racket to see if errortrace now works better for your
application.


It is better, however not to an extent that would make it usable for my project.
It came down from ~10x to ~6x.

Racket 6.7 or nightly, no errortrace: 17 seconds, ~260 MB of RAM
Racket 6.7 + errortrace  : 150 seconds, 2600+ MB of RAM
Racket nightly + errortrace : 118 seconds, ~1600 MB of RAM

As I wrote previously, I have no urgent need to have errortrace's
demands lowered further, since I got around with hand-made continuation marks.

However, I will surely provide any information about my program,
in case such information is needed to debug errortrace's behavior.
I will be happy to get back to errortrace in the future.


Best regards,

Dmitry

--
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] errortrace requires 10x time and memory for the program to compile

2016-12-06 Thread Dmitry Pavlov

Robby,

On 12/06/2016 07:20 PM, Robby Findler wrote:

I'm not sure if it helps, but errortrace fully expands your program
and then traverses that and adds continuation marks (this is called
"annotation" in the errortrace docs). There may be a bug in this
process that causes information to be lost, I suppose, but the problem
with the dynamically required module may also be that it didn't
annotate it. It won't annotate it if there is a .zo file already, I
believe.

errortrace did add its continuation marks into the dynamically loaded module.
It was the build-in Racket's (current-continuation-marks) who did not succeed 
in that.
errortrace works great in principle, but too slow in some cases.


Best regards,

Dmitry

--
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] errortrace requires 10x time and memory for the program to compile

2016-12-06 Thread Dmitry Pavlov



I guess, under these circumstances, I should
try and make my own continuation marks in the parser/compiler.


I managed to to that. I can not say that it is a beautiful implementation, but 
it works.

For "a+b",  instead of a syntax object of '(plus a b),
the parser now generates a syntax object of
'(with-cont-mark (plus a b)), and my compiler replaces it with
(with-continuation-mark my-generated-mark-key scrloc (plus a b))
where srcloc is calculated from the syntax object.

So the same source location is specified twice: first in the custom 
continuation mark, for my custom diagnostics, and second in the syntax object 
itself, for Racket standard diagnostics.

I wonder how errortrace manages to thread the continuation marks through all 
the syntax transformers without them noticing.

In general, I have a vague feeling that I am making inferior ad-hoc Racket 
tools for tasks that are solved in Racket itself with better tools. An issue 
that I find similar was reported by Konrad Hinsen earlier this year: 
http://www.mail-archive.com/racket-users@googlegroups.com/msg32937.html

Best regards,

Dmitry

--
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] errortrace requires 10x time and memory for the program to compile

2016-12-05 Thread Dmitry Pavlov



I just tried that: unfortunately, this stack trace does not seem to
be able to cross the boundary of dynamically required module.



What I see in (continuation-mark-set->context (current-continuation-marks))
are just lines in the "main" Racket module, and no lines that
belong to the non-sexp module or deeper.


And (continuation-mark-set->context (exn-continuation-marks e))
do cross the boundary, but show only some deeper lines in deeper modules,
not in the "top" dynamically required module.

Best regards,

Dmitry

--
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] errortrace requires 10x time and memory for the program to compile

2016-12-05 Thread Dmitry Pavlov

Matthew,



Question 1: A factor of 10 is on the high side, but not unusual at the
moment.

There's a pending issue of making sure that `for` loops or other things
are not needlessly instrumented, since they're only part of the
expansion instead of the original code. We haven't gotten back to that,
but I bet it would help with your program.



Question 2: No, unfortunately.


OK, got it.


Question 3: If the built-in, approximate stack trace is good enough,
you can get it with

 (continuation-mark-set->context (current-continuation-marks))


I just tried that: unfortunately, this stack trace does not seem to
be able to cross the boundary of dynamically required module.
Or, to be precise, the module that is required via
(require-input-port) -- the function that you kindly wrote for me
three years ago:
https://lists.racket-lang.org/users/archive/2013-September/059449.html

What I see in (continuation-mark-set->context (current-continuation-marks))
are just lines in the "main" Racket module, and no lines that
belong to the non-sexp module or deeper.

Actually, all I need is the line number of the non-sexp file where
the error originated from. I guess, under these circumstances, I should
try and make my own continuation marks in the parser/compiler.

Best regards,

Dmitry

--
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] errortrace requires 10x time and memory for the program to compile

2016-12-05 Thread Dmitry Pavlov

Hello,

I have a program that takes 17 seconds and ~260 MB of memory.
If I use errortrace on it, the numbers grow about tenfold: 150 seconds and 
2600+ MB.

That is just compilation; in the runtime the program does almost nothing and 
terminates quickly.
I know little about how errortrace works and ask for help.
My understanding of the problem is shaped into three questions.

Question 1. Is it normal for errortrace?

Note 1: I am using errortrace just for getting the stack trace of a runtime 
error:

(with-handlers
  ((exn:fail?
(lambda (e)
  (for ((stack-elem (continuation-mark-set->list
 (exn-continuation-marks e) errortrace-key)))
 ..


Note 2: The program which stack trace I am interested in is require-d
dynamically, and is actually written in non-lispy language.
errortrace does a great job in planting its continuation marks
into syntax objects that are generated by the parser and
the compiler for that language.


Question 2: Is there an option for errortrace to reduce its time and memory
consumption and still provide the continuation marks for stack trace?
I tried (profiling-record-enabled #f), it did not help.

Question 3: Is there another way to programmatically get a stack trace for a
dynamically loaded program? Am I using a sledgehammer to crack a nut?


Best regards,

Dmitry

--
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] list-free syntax

2016-11-19 Thread Dmitry Pavlov



Without the macro, the last line would have been
(some-func ((parameter-1) some-arg)


The question comes when you would have used (parameter-1) in a higher-order 
context. Do you want it to be equivalent to (parameter-1), or equivalent to 
(lambda (arg ...) ((parameter-1) arg ...)) ?

In your source program the first way would mean that parameter-1 and (lambda 
(arg ...) (parameter-1 arg ...)) would be different. But the second way they 
would be the same, because they would both be lambdas that would use the value 
from when it was called instead of when it was created.

If you know that the parameter is never modified within other than through that 
single parameterize, and if you can be absolutely sure that the value of this 
never escapes the context of that single parameterize through anything else, 
then there won't be any observable difference. However if it does escape 
somehow, you need to figure out what that should mean.


Agreed; if the parameters were potentially modifiable, I would have thought 
twice before de-parenthesizing them.

Best regards,

Dmitry

--
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] list-free syntax

2016-11-19 Thread Dmitry Pavlov



On 11/20/2016 12:04 AM, Dmitry Pavlov wrote:




On 11/19/2016 11:45 PM, Alex Knauth wrote:



On Nov 19, 2016, at 1:51 PM, Dmitry Pavlov <dpav...@iaaras.ru> wrote:


Out of curiosity, why do you want this?


I have a bunch of parameters (in the Racket sense of the word)
that are "read-only" throughout the module, i.e. there are no
modifications via calls (parameter value).

Most of parameters' values are themselves functions.

So what I wanted to save a couple of parentheses on
function calls: (parameter arg ...)
instead of ((parameter) arg ...)


Here's a question: do you want `parameter` to be a recond of the value of the 
parameter at that time, or do you want it to be a function that, when called, 
uses the current value then?


The former, I think.


No, the latter!





For example if you say
(use-f parameter)

Where
(define (use-f f)
  (do-something-that-could-affect-the-parameter)
  (f arg ...))

Using one strategy this would still use the old value of the parameter, and 
using the other it would use the new version after 
(do-something-that-could-affect-the-parameter). Which do you want?



There are no modification of parameters, aside from a single (parameterize).
My parameters are "global", are not passed between functions, and are 
(require)-d from another module.
There are other modules the parameters are (require)-d into.
I use parameters to avoid the pain of passing everything to every function on 
the way.
(If there is another way to do that in Racket, I would be happy to know.)

My code is basically this

(require a-module-with-parameters)

(define (main)
  (parameterize ((parameter1 (determine-value-for-parameter-1-basing-on-input))
 (parameter2 (determine-value-for-parameter-2-basing-on-input))
  ...)
(subroutine-1)
(subroutine-2)
...
   ))

(define (subroutine-1)
  (sub-subroutine-3))

(define (sub-subroutine-3)
  (some-func (parameter-1 some-arg))


Without the macro, the last line would have been
(some-func ((parameter-1) some-arg)


Best regards,

Dmitry



--
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] list-free syntax

2016-11-19 Thread Dmitry Pavlov




On 11/19/2016 11:45 PM, Alex Knauth wrote:



On Nov 19, 2016, at 1:51 PM, Dmitry Pavlov <dpav...@iaaras.ru> wrote:


Out of curiosity, why do you want this?


I have a bunch of parameters (in the Racket sense of the word)
that are "read-only" throughout the module, i.e. there are no
modifications via calls (parameter value).

Most of parameters' values are themselves functions.

So what I wanted to save a couple of parentheses on
function calls: (parameter arg ...)
instead of ((parameter) arg ...)


Here's a question: do you want `parameter` to be a recond of the value of the 
parameter at that time, or do you want it to be a function that, when called, 
uses the current value then?


The former, I think.



For example if you say
(use-f parameter)

Where
(define (use-f f)
  (do-something-that-could-affect-the-parameter)
  (f arg ...))

Using one strategy this would still use the old value of the parameter, and 
using the other it would use the new version after 
(do-something-that-could-affect-the-parameter). Which do you want?



There are no modification of parameters, aside from a single (parameterize).
My parameters are "global", are not passed between functions, and are 
(require)-d from another module.
There are other modules the parameters are (require)-d into.
I use parameters to avoid the pain of passing everything to every function on 
the way.
(If there is another way to do that in Racket, I would be happy to know.)

My code is basically this

(require a-module-with-parameters)

(define (main)
  (parameterize ((parameter1 (determine-value-for-parameter-1-basing-on-input))
 (parameter2 (determine-value-for-parameter-2-basing-on-input))
  ...)
(subroutine-1)
(subroutine-2)
...
   ))

(define (subroutine-1)
  (sub-subroutine-3))

(define (sub-subroutine-3)
  (some-func (parameter-1 some-arg))


Without the macro, the last line would have been
(some-func ((parameter-1) some-arg)


Best regards,

Dmitry

--
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] list-free syntax

2016-11-19 Thread Dmitry Pavlov




Out of curiosity, why do you want this?


I have a bunch of parameters (in the Racket sense of the word)
that are "read-only" throughout the module, i.e. there are no
modifications via calls (parameter value).

Most of parameters' values are themselves functions.

So what I wanted to save a couple of parentheses on
function calls: (parameter arg ...)
instead of ((parameter) arg ...)

Best regards,

Dmitry

--
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] list-free syntax

2016-11-19 Thread Dmitry Pavlov

Alex,



Using that your macro would be:

(define-syntax call-my-func
  (make-variable-like-transformer #'(my-func)))


Perfect solution, thank you!

I read about make-rename-transformer, but make-variable-like-transformer 
escaped me.

Best regards,

Dmitry

--
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] list-free syntax

2016-11-19 Thread Dmitry Pavlov


OK, it seems that I have found the way:

(define-syntax (call-my-func stx)
  (syntax-parse stx
[x:id #'(my-func)]
[(x:id) #'((my-func))]
[(x:id arg ...) #'((my-func) arg ...)])
)

It suits my needs, although is not as simple as would
be a "replace call-my-func with (my-func) disregarding
the circumstances" macro.
Just out of curiosity: is the latter possible?

Best regards,

Dmitry


On 11/19/2016 01:10 PM, Dmitry Pavlov wrote:

Hello,

I was wondering how I can define a macro that acts without parentheses.
Here is what I came up with:

(define (my-func) "abc")

(define-syntax (call-my-func stx)
(syntax-case stx ()
  (_ #'(my-func


It was fine at the first glance:


call-my-func

"abc"

But then I tried


(call-my-func)

"abc"

This pose a problem to me in the case when (my-func) returns not
a constant but a function to be called.
Besides, it breaks my common sense of Lisp that is
"an extra pair of parentheses does change things".

Could anybody school me on this topic please?

Best regards,

Dmitry



--
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] Error messages in DSL implementations

2016-10-24 Thread Dmitry Pavlov



Is it compile-time or run-time errors?


Mostly module-instantiation-time errors, which are closer to run-time 
errors.


As a simple example, consider syntactically correct DSL code that 
expands to


  (define foo (first '()))

The call to first raises an exception, which is displayed without any 
reference to the original DSL code, and is therefore incomprehensible 
to the DSL's users.


I believe the DSL code should expand to syntax objects that do keep the 
reference to the original DSL code.
It they do, the Racket's runtime error trace tool will trace the error 
up to the DSL (though it may show to user some Racket code in the way).
As an example of a DSL parser that attaches source information to syntax 
objects it generates, you can look e.g. at [1], see b-syn macro.


Sorry for the noise if I am just misunderstanding the whole question.

Best regards,

Dmitry


[1] 
http://planet.racket-lang.org/package-source/wrturtle/pyret.plt/1/2/bsl/parse.rkt


--
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] Error messages in DSL implementations

2016-10-24 Thread Dmitry Pavlov

Konrad,

Is it compile-time or run-time errors?

Assuming compile-time, I would suggest an approach I took for a non-SEXP 
language: call raise-syntax-error in the (custom) compiler, which runs 
after parser and transforms syntax objects to other syntax objects. The 
third argument of raise-syntax-error can be a syntax object causing the 
error -- which allows to refer to the original source in a nice and 
natural way.


Best regards,

Dmitry

On 10/24/2016 04:25 PM, Konrad Hinsen wrote:

Hi everyone,

I am working on a DSL embedded in Racket (for the curious, it's on 
GitHub: https://github.com/khinsen/leibniz) and as I am starting to 
use my DSL in practice, I wish my implementation had better error 
reporting.


My DSL consists of a bunch of syntax transformers that expand to 
Racket code that constructs some complex data structure. The errors I 
care about are not syntax errors, but inconsistencies detected during 
the construction of the data structures. I would like those error 
messages to refer to the source of the input language, rather than to 
the code of the DSL implementation, which a DSL user shouldn't have to 
know about.


I can think of a few approaches, such as redefining 
error-display-handler in the expanded code, but I suspect that others 
have already found better solutions to this problem. I'd be grateful 
for any pointers.


Konrad.




--
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] date->seconds complaining about a supposedly non-existent date

2016-10-20 Thread Dmitry Pavlov




That was more intended as a rant about things that drive me batty than 
actual instruction -- I hope it didn't come across as patronizing.

No, not at all.

One of the things that surprised me the most is that prior to 1925, 
astronomers kept timestamps of their observations where day started at 
noon, not at midnight---for keeping the day constant through the 
observation session.


By the way, a question to Racket developers: is Racket ready for year 2038?

Best regards,

Dmitry

--
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] date->seconds complaining about a supposedly non-existent date

2016-10-20 Thread Dmitry Pavlov

David,

Yes, I deal with most of this at work, except daylight savings. 
(Timestamps in astronomical observations are predominantly in UTC or 
rarely TT/TDB, I never saw local time.)


Best regards,

Dmitry


On 10/20/2016 07:26 PM, David Storrs wrote:
Also be aware that once you start getting into date math you need to 
deal with:


*) Minutes that might have 61 seconds in them.  Yes, hh:mm:60 is a 
real time.


*) Hours that don't exist.

*) Hours that happen twice in the same day.

*) Februaries that have 28 or 29 days on a weird schedule. (If the 
year is divisible by 4, unless it's divisible by 100, unless it's 
divisible by 400.)


*) Two weeks that didn't exist due to calendars switching over.

*) The modern calendar being adopted at different points in different 
countries.  Greece didn't start using it until 1923.


On Thu, Oct 20, 2016 at 12:13 PM, Matthew Flatt <mfl...@cs.utah.edu 
<mailto:mfl...@cs.utah.edu>> wrote:


Did you timezone use daylight saving in 1996?

In U.S. timezones, March (it used to be April) has a 1-hour hole
due to
the switch to daylight saving time, where the clock skips forward from
1:59am to 3:00am. For example, 2:47:59am on March 13, 2016 really did
not exist in my timezone.

At Thu, 20 Oct 2016 19:05:38 +0300, Dmitry Pavlov wrote:
> Hello,
>
> The surprise of the day for me is date->seconds
> rejecting a particular time on a particular date.
>
> (date->seconds (date 59 47 2 31 3 1996 0 0 #f 0))
>
> This should be 1996, March 31, 02:47:59 am, correct?
>
>
> It reports the following error:
>
> find-seconds: non-existent date
>wanted: (59 47 2 31 3 1996)
>nearest below: 828226799 is (59 59 1 31 3 1996)
>nearest above: 828226800 is (0 0 3 31 3 1996)
>context...:
> /opt/racket/collects/racket/date.rkt:234:0: date->seconds
>   
 /opt/racket/collects/racket/contract/private/arrow-val-first.rkt:306:25

> /opt/racket/collects/racket/private/misc.rkt:88:7
>
>  From the message, I can suppose that it misses a whole hour inside.
>
> What can be done?
>
> This is Racket 6.6 on Linux.
>
>
> Best regards,
>
> Dmitry
>
> --
> 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
<mailto:racket-users%2bunsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout
<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
<mailto:racket-users%2bunsubscr...@googlegroups.com>.
For more options, visit https://groups.google.com/d/optout
<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] date->seconds complaining about a supposedly non-existent date

2016-10-20 Thread Dmitry Pavlov

Matthew,



Did you timezone use daylight saving in 1996?



Oh, right.

I need UTC date and time; I assumed it is UTC since I passed #f for dst? 
and 0 for time-zone-offset in (date). I missed the local-time? flag in 
date->seconds, which is true by default.


So the corrected version of my code
(date->seconds (date 59 47 2 31 3 1996 0 0 #f 0) #f)
works fine.

Thank you for such a fast response.

Best regards,

Dmitry

--
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] date->seconds complaining about a supposedly non-existent date

2016-10-20 Thread Dmitry Pavlov

Hello,

The surprise of the day for me is date->seconds
rejecting a particular time on a particular date.

(date->seconds (date 59 47 2 31 3 1996 0 0 #f 0))

This should be 1996, March 31, 02:47:59 am, correct?


It reports the following error:

find-seconds: non-existent date
  wanted: (59 47 2 31 3 1996)
  nearest below: 828226799 is (59 59 1 31 3 1996)
  nearest above: 828226800 is (0 0 3 31 3 1996)
  context...:
   /opt/racket/collects/racket/date.rkt:234:0: date->seconds
   /opt/racket/collects/racket/contract/private/arrow-val-first.rkt:306:25
   /opt/racket/collects/racket/private/misc.rkt:88:7

From the message, I can suppose that it misses a whole hour inside.

What can be done?

This is Racket 6.6 on Linux.


Best regards,

Dmitry

--
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] Spreadsheet widget?

2016-09-03 Thread Dmitry Pavlov

David,


   invalid symbol: 'hide-hscroll
   given: '(hide-hscroll)
This is relatively new in Racket GUI. (Matthew added this option at my 
request not long ago).
If you can update your Racket installation to the latest version, it is 
probably the easiest way to get past this error.


Best regards,

Dmitry

--
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] Error message from GUI

2016-08-29 Thread Dmitry Pavlov

Hello,

Sorry for dropping out of the conversation for a while.

Here is the smallest example that I could produce:

#lang racket

(require racket/gui
 racket/draw
 table-panel)

(define test%
  (class
  table-panel% (super-new (dimensions '(1 1)))
  ;vertical-panel% (super-new)
  ;horizontal-panel% (super-new)

(define vpanel
  (new vertical-panel%
   (parent this)
   (border 0)
   (style '(vscroll))
   ;(min-height 1)
   ))

(for ((i (in-range 10)))
  (new button%
   (parent vpanel)
   (label (format "Button ~a" i))
   ))
))


(define frame
  (instantiate frame% ("Test")))

(void (new test% (parent frame)))

(send frame resize 200 200)
(send frame show #t)


On Windows, it results into:
..\..\Program 
Files\Racket\share\pkgs\draw-lib\racket\draw\private\syntax.rkt:252:13: 
initialization for bitmap%: bad argument combination: 192 0 #f #t 1.0


On Linux, it works, although the vertical panel ends up with a small 
visible size.


If I specify a min-height at least one to the vertical  panel, the error 
is gone, and the panel is the size of the window.
If I use vertical-panel% or horizontal-panel% instead of table-panel%, 
the error is gone, and the panel is the size of the window.


So the problem here is that table-panel% handles its children in a 
certain way, and that the height of the scrollable panel ends up zero.


I did not write table-panel. I currently do not know whether a fix 
should be done in table-panel or gui-lib.


In my program, (min-height 1) helps, so I can live with the way it is now.

Best regards,

Dmitry




On 07/30/2016 12:44 AM, Vincent St-Amour wrote:

Should this change be added to gui-lib?

Vincent


On Fri, 29 Jul 2016 10:08:46 -0500,
Dmitry Pavlov wrote:

Matthew,

Yes that works, thank!

Also I figured why the message did not show up on my "first" WinXP
installation: the spreadsheet-editor package has not been updated there.
Newer version of spreadsheet-editor sets (style '(hide-vscroll)) and
(style '(hide-hscroll)) to panels with row and column buttons.

Styles cause the error. Changing styles to just '(hscroll) and
'(vscroll) does not remove the error.
Anyway, I need those (hide-vscroll) and (hide-hscroll), so I am going to
use the patch you proposed, unless there is a more elegant solution I am
unaware of.

(Another question is why there is a stack trace in 32-bit Windows and
just a message in 64-bit Windows, but that is of purely theoretical
importance to me.)

Best regards,

Dmitry


On 07/29/2016 05:25 PM, Matthew Flatt wrote:

It may be that a guard against a 0-sized drawing dimension is needed.
The right place for the guard might be in the `get-cr` method of

   gui-lib/mred/private/wx/common/backing-dc.rkt

after `get-backing-size` is called. A zero dimension could be just
increased to 1 before passing it to `get-backing-bitmap`. Can you try
making that change to see if it solves the problem on your machine?

At Fri, 29 Jul 2016 17:08:42 +0300, Dmitry Pavlov wrote:

Jens,

Oddly, another installation of Racket 6.6 on 32-bit Windows XP not only
reproduced the error, but also gave a stack trace:

initialization for bitmap%: bad argument combination: 495 0 #f #t 1.25
 context...:
  C:\Program
Files\Racket\share\pkgs\draw-lib\racket\draw\private\syntax.rkt:252:13: next
  C:\Program
Files\Racket\share\pkgs\draw-lib\racket\draw\private\bitmap.rkt:156:2
  C:\Program
Files\Racket\collects\racket\private\class-internal.rkt:3553:0:
continue-make-object
  C:\Program
Files\Racket\collects\racket\private\class-internal.rkt:3507:0:
do-make-object
  C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\backing-dc.rkt:122:4:
get-cr method in backing-dc%
  C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\canvas-mixin.rkt:144:4:
do-on-paint method in ...mon/canvas-mixin.rkt:118:2
  C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:454:6
  C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:505:32
  C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:653:3

bitmap.rkt confirms your hypothesis that the first number is the width,
and the second number is the height, and they both must be positive.

  [([exact-positive-integer? w]
[exact-positive-integer? h]
[any? [b? #f]]
[any? [alpha? #f]]
[positive-real? [scale 1.0]])

The width is not specified exactly in the app. I do not know why the
height is zero. I do not use bitmaps directly, just controls and canvas.
I will go with trial and error to get a small reproducible example.

Regards,

Dmitry


On 07/28/2016 11:50 PM, Jens Axel Søgaard wrote:

Just a hunch: If 486 is a width - then the 0 could be a problematic
height?

Do you recognize the number 486?

/Jens Axel


2016-07-28 22:29 GMT+02:00 &

Re: [racket-users] Error message from GUI

2016-07-29 Thread Dmitry Pavlov

Matthew,

Yes that works, thank!

Also I figured why the message did not show up on my "first" WinXP 
installation: the spreadsheet-editor package has not been updated there.
Newer version of spreadsheet-editor sets (style '(hide-vscroll)) and 
(style '(hide-hscroll)) to panels with row and column buttons.


Styles cause the error. Changing styles to just '(hscroll) and 
'(vscroll) does not remove the error.
Anyway, I need those (hide-vscroll) and (hide-hscroll), so I am going to 
use the patch you proposed, unless there is a more elegant solution I am 
unaware of.


(Another question is why there is a stack trace in 32-bit Windows and 
just a message in 64-bit Windows, but that is of purely theoretical 
importance to me.)


Best regards,

Dmitry


On 07/29/2016 05:25 PM, Matthew Flatt wrote:

It may be that a guard against a 0-sized drawing dimension is needed.
The right place for the guard might be in the `get-cr` method of

  gui-lib/mred/private/wx/common/backing-dc.rkt

after `get-backing-size` is called. A zero dimension could be just
increased to 1 before passing it to `get-backing-bitmap`. Can you try
making that change to see if it solves the problem on your machine?

At Fri, 29 Jul 2016 17:08:42 +0300, Dmitry Pavlov wrote:

Jens,

Oddly, another installation of Racket 6.6 on 32-bit Windows XP not only
reproduced the error, but also gave a stack trace:

initialization for bitmap%: bad argument combination: 495 0 #f #t 1.25
context...:
 C:\Program
Files\Racket\share\pkgs\draw-lib\racket\draw\private\syntax.rkt:252:13: next
 C:\Program
Files\Racket\share\pkgs\draw-lib\racket\draw\private\bitmap.rkt:156:2
 C:\Program
Files\Racket\collects\racket\private\class-internal.rkt:3553:0:
continue-make-object
 C:\Program
Files\Racket\collects\racket\private\class-internal.rkt:3507:0:
do-make-object
 C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\backing-dc.rkt:122:4:
get-cr method in backing-dc%
 C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\canvas-mixin.rkt:144:4:
do-on-paint method in ...mon/canvas-mixin.rkt:118:2
 C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:454:6
 C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:505:32
 C:\Program
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:653:3

bitmap.rkt confirms your hypothesis that the first number is the width,
and the second number is the height, and they both must be positive.

 [([exact-positive-integer? w]
   [exact-positive-integer? h]
   [any? [b? #f]]
   [any? [alpha? #f]]
   [positive-real? [scale 1.0]])

The width is not specified exactly in the app. I do not know why the
height is zero. I do not use bitmaps directly, just controls and canvas.
I will go with trial and error to get a small reproducible example.

Regards,

Dmitry


On 07/28/2016 11:50 PM, Jens Axel Søgaard wrote:

Just a hunch: If 486 is a width - then the 0 could be a problematic
height?

Do you recognize the number 486?

/Jens Axel


2016-07-28 22:29 GMT+02:00 <dpav...@iaaras.ru <mailto:dpav...@iaaras.ru>>:

 Hello,

 Running my GUI app from Racket 6.6, I see the following error
 message in the console:

 initialization for bitmap%: bad argument combination: 486 0 #f #t 1.0

 It happens on 64-bit Windows 7 and 10, and does not happen on
 32-bit Windows XP and 64-bit Linux.

 It also did not happen on Racket 6.5.

 The app continues to work despite the error. There is no stack
 trace whatsoever.
 What can I do to trace the problem?


 Best regards,

 Dmitry

 --
 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
 <mailto:racket-users%2bunsubscr...@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] Error message from GUI

2016-07-29 Thread Dmitry Pavlov

Jens,

Oddly, another installation of Racket 6.6 on 32-bit Windows XP not only 
reproduced the error, but also gave a stack trace:


initialization for bitmap%: bad argument combination: 495 0 #f #t 1.25
  context...:
   C:\Program 
Files\Racket\share\pkgs\draw-lib\racket\draw\private\syntax.rkt:252:13: next
   C:\Program 
Files\Racket\share\pkgs\draw-lib\racket\draw\private\bitmap.rkt:156:2
   C:\Program 
Files\Racket\collects\racket\private\class-internal.rkt:3553:0: 
continue-make-object
   C:\Program 
Files\Racket\collects\racket\private\class-internal.rkt:3507:0: 
do-make-object
   C:\Program 
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\backing-dc.rkt:122:4: 
get-cr method in backing-dc%
   C:\Program 
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\canvas-mixin.rkt:144:4: 
do-on-paint method in ...mon/canvas-mixin.rkt:118:2
   C:\Program 
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:454:6
   C:\Program 
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:505:32
   C:\Program 
Files\Racket\share\pkgs\gui-lib\mred\private\wx\common\queue.rkt:653:3


bitmap.rkt confirms your hypothesis that the first number is the width, 
and the second number is the height, and they both must be positive.


   [([exact-positive-integer? w]
 [exact-positive-integer? h]
 [any? [b? #f]]
 [any? [alpha? #f]]
 [positive-real? [scale 1.0]])

The width is not specified exactly in the app. I do not know why the 
height is zero. I do not use bitmaps directly, just controls and canvas.

I will go with trial and error to get a small reproducible example.

Regards,

Dmitry


On 07/28/2016 11:50 PM, Jens Axel Søgaard wrote:
Just a hunch: If 486 is a width - then the 0 could be a problematic 
height?


Do you recognize the number 486?

/Jens Axel


2016-07-28 22:29 GMT+02:00 >:

Hello,

Running my GUI app from Racket 6.6, I see the following error
message in the console:

initialization for bitmap%: bad argument combination: 486 0 #f #t 1.0

It happens on 64-bit Windows 7 and 10, and does not happen on
32-bit Windows XP and 64-bit Linux.

It also did not happen on Racket 6.5.

The app continues to work despite the error. There is no stack
trace whatsoever.
What can I do to trace the problem?


Best regards,

Dmitry

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


Re: [racket-users] GUI: clipping of controls fails on Linux but not on Windows

2016-05-19 Thread Dmitry Pavlov

Matthew,


Second thought was to check the latest snapshot (d0d85b2, commit in
racket/racket made ~3h later than yours in racket/gui). That did not
work, too -- the commit of interest is not included into the snapshot.

That should have worked, and it looks to me like the change is included
in the d0d85b2 snapshots. (I downloaded a source distribution from both
the Utah and NWU sites to check.) Can you say more about which one you
downloaded and why the change seems to be missing?


Oh, it has turned out that I executed the wrong (old) installer instead 
of the snapshot's.
I got it working, thank you! I am sorry for wasting your time on 
checking the snapshot.


Best regards,

Dmitry

--
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] GUI: clipping of controls fails on Linux but not on Windows

2016-05-19 Thread Dmitry Pavlov

Matthew,

On 05/19/2016 12:33 AM, Matthew Flatt wrote:

There's not a good way to do this outside the primitives, because it's
a matter of selecting the right GTK widgets.

I've added 'hide-hscroll and 'hide-vscroll, which are like 'hscroll and
'vscroll (i.e., they allow the panel's size to be smaller than its
content) but never show the corresponding scrollbar.
Thank you so much. I am eager to try this new feature. I can not figure 
a good way to set it up on my machine.
I have Racket 6.5 release. My first thought was "let me try this new 
package system":


$ sudo raco pkg update gui
Inferred package scope: installation
Resolving "gui" via https://download.racket-lang.org/releases/6.5/catalog/
Resolving "gui-lib" via 
https://download.racket-lang.org/releases/6.5/catalog/
Resolving "gui-doc" via 
https://download.racket-lang.org/releases/6.5/catalog/

No updates available

Second thought was to check the latest snapshot (d0d85b2, commit in 
racket/racket made ~3h later than yours in racket/gui). That did not 
work, too -- the commit of interest is not included into the snapshot.


What would you recommend? Is there a catalog similar to Debian 
"unstable" repo that I can sync to?


Best regards,

Dmitry





At Wed, 18 May 2016 23:37:02 +0300, Dmitry Pavlov wrote:

Matthew,

  > One possible fix is to add the 'hscroll style to the horizontal panel.
  > That change moves the program into "defined behavior" territory, since
  > a scrolling panel allows its content to be wider than itself.

I just tried that and I see that it shows a scrollbar under the
panel that I would not like the user to see. Is there a way to hide it?


That is indeed in "undefined behavior" territory for the GUI library,
because `racket/gui` doesn't pin down what happens when widgets overlap
(including panels and buttons).

OK, but the panel with 'hscroll somehow handles the controls that go
outside of the panel's geometry, can I do the same manually?
Or the scrolling mechanism is hidden in a primitive?


Best regards,

Dmitry

--
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] GUI: clipping of controls fails on Linux but not on Windows

2016-05-18 Thread Dmitry Pavlov

Matthew,

> One possible fix is to add the 'hscroll style to the horizontal panel.
> That change moves the program into "defined behavior" territory, since
> a scrolling panel allows its content to be wider than itself.

I just tried that and I see that it shows a scrollbar under the
panel that I would not like the user to see. Is there a way to hide it?


That is indeed in "undefined behavior" territory for the GUI library,
because `racket/gui` doesn't pin down what happens when widgets overlap
(including panels and buttons).


OK, but the panel with 'hscroll somehow handles the controls that go
outside of the panel's geometry, can I do the same manually?
Or the scrolling mechanism is hidden in a primitive?


Best regards,

Dmitry

--
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] GUI: clipping of controls fails on Linux but not on Windows

2016-05-18 Thread Dmitry Pavlov

Hello,

I would like to report two GUI issues; I do not know is they are related 
or not. I ran against those issues while working on spreadsheet-editor.
The task is to clip a row of buttons (column buttons in my spreadsheet). 
Below I reproduce the issue using a simpler configuration than I use in 
spreadsheet-editor.


I can reproduce both issues on Linux; on Windows everything is OK. I do 
not have an OS X to test on. I have a vague memory that everything was 
fine on Linux, too, before Racket moved to GTK+3, but I may be wrong.


1. Clipping of graphics does not work

#lang racket/gui

(define frame
  (new frame%
(label "Test")
(width 300)
(height 50)))

(define my-horizontal-panel%
  (class horizontal-panel%
(super-new)

(define/override (container-size info)
  (values 50 50))
))

(define hpanel-root
  (new horizontal-panel%
   (parent frame)))

(define hpanel
  (new my-horizontal-panel%
   (parent hpanel-root)))

(define vpanel
  (new vertical-panel%
   (parent hpanel-root)
   (stretchable-height #f)
   (stretchable-width #f)))

(for ((i (in-range 5)))
  (new button%
   (parent hpanel)
   (label "Hey")
   (callback
 (lambda (button event)
   (printf "Hey\n")

(void (new button%
   (parent vpanel)
   (label "Fixed size button 1")))
(void (new button%
   (parent vpanel)
   (label "Fixed size button 2")))
(send frame show #t)


On Linux, I get: http://imgur.com/AZRji9R
On Windows, I get: http://imgur.com/eKUZ2kk

Obviously, the Linux version did not clip the row of buttons as it is 
supposed to. Still, the mouse works only on just that area of the button 
that is supposed to be there. That is a bit reassuring until you look at 
the second example.




2. Clipping of events does not work in presence of begin-container-sequence

This example is identical to the first one except that the five buttons 
are (re)created inside (on-size).


#lang racket/gui

(define frame
  (new frame%
(label "Test")
(width 300)
(height 50)))

(define my-horizontal-panel%
  (class horizontal-panel%
(super-new)

(define/override (container-size info)
  (values 50 50))

(define/override (on-size w h)
  (send this begin-container-sequence)
  (for ((child (send this get-children)))
(send this delete-child child))

  (for ((i (in-range 5)))
(new button%
 (parent this)
 (label "Hey")
   (callback
(lambda (button event)
  (printf "Hey\n")
  (send this end-container-sequence))
))

(define my-super-panel%
  (class horizontal-panel%
(super-new)))

(define hpanel-root
  (new horizontal-panel%
   (parent frame)))

(define hpanel
  (new my-horizontal-panel%
   (parent hpanel-root)))

(define vpanel
  (new vertical-panel%
   (parent hpanel-root)
   (stretchable-height #f)
   (stretchable-width #f)))

(void (new button%
   (parent vpanel)
   (label "Fixed size button 1")))
(void (new button%
   (parent vpanel)
   (label "Fixed size button 2")))

(send frame show #t)


The Linux and Windows pictures are the same as for the first example; 
but in this one, "Hey" can be pressed anywhere, even in the areas that 
are below the big buttons.



I will be grateful for any advice, including possible workarounds. I am 
not even sure that my programs are legit and do not just fall victim of 
"undefined behavior".


Best regards,

Dmitry

--
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: Running racket on a #lang-less module-less file?

2016-05-07 Thread Dmitry Pavlov

Jack,


There exists a language that wasn't initially designed with racket in mind, but 
could easily be a racket #lang. To interop with code already written in this 
language, I wanted an easy way to run files that don't have the #lang line.
I had a very similar case when I had to create a command-line program 
that runs files written in some DSL without #lang in them. Below is what 
I came up with. The prefix-input-port and require-input-port routines 
came from Matthew Flatt: he wrote them at my request in this newsgroup a 
couple years ago. Thank you again Matthew, I still use them.


Best regards,

Dmitry


#lang racket

(require syntax/modread
 errortrace
 errortrace/errortrace-key)

;; prefix-input-port : bytes input-port -> input-port
;;  Directs position requests to the given port after the
;;  prefix is read.
;;  Closes the given input port when the result port is closed.
(define (prefix-input-port prefix base-p)
  (define-values (prefix-i prefix-o) (make-pipe))
  (write-bytes prefix prefix-o)
  (close-output-port prefix-o)
  (define (prefix-done?)
(zero? (pipe-content-length prefix-i)))

  (make-input-port
   (object-name base-p)
   ;; read
   (lambda (bstr)
 (define n (read-bytes-avail!* bstr
   (if (prefix-done?)
   base-p
   prefix-i)))
 (if (equal? n 0)
 (wrap-evt base-p (lambda (v) 0))
 n))
   ;; peek
   (lambda (bstr offset evt)
 (define pre-n (pipe-content-length prefix-i))
 (define n (if (offset . >= . pre-n)
   (peek-bytes-avail!* bstr
   (- offset pre-n)
   #f
   base-p)
   (peek-bytes-avail!* bstr
   offset
   #f
   prefix-i)))
 (if (equal? n 0)
 (wrap-evt base-p (lambda (v) 0))
 n))
   ;; close
   (lambda ()
 (close-input-port base-p))
   ;; get-progress-evt
   ;;  Difficult (impossible?) to support at the
   ;;  prefix--base boundary.
   #f
   ;; commit
   #f
   ;; get-location
   (lambda ()
 (if (prefix-done?)
 (port-next-location base-p)
 (port-next-location prefix-i)))
   ;; count-lines!
   (lambda ()
 (port-count-lines! prefix-i)
 (port-count-lines! base-p

(define (require-input-port p [name (gensym)])
  (define module-name (make-resolved-module-path name))
  (parameterize ([current-module-declare-name module-name])
(eval-syntax (check-module-form ; ensures that `module` is bound
  (with-module-reading-parameterization
   (lambda ()
 (read-syntax (object-name p) p)))
  'ignored
  #f)))
  (dynamic-require module-name #f))

(define (normalize-error-location location)
  (list
   ;; decrement the line number to take our #lang line back
   (sub1 (first location))
   ;; increment the column number: in Racket ports, column numbers
   ;; are 0-based, while we want 1-based
   (add1 (second location

(define (run path)
  (define p
(prefix-input-port
 #"#lang mylang\n"
 (open-input-file path)))
  (port-count-lines! p)
  (define path-norm (normalize-path path))
  (define error-location (void))
  (define error-message (void))
  (with-handlers
  ((exn:fail:syntax?
(lambda (e)
  (set! error-message (exn-message e))
  (let ((stx (last (exn:fail:syntax-exprs e
(when (equal? (normalize-path (syntax-source stx)) path-norm)
  (set! error-location
(normalize-error-location (list (syntax-line stx)
(syntax-column stx)
)))
   (exn:fail?
(lambda (e)
  (set! error-message (exn-message e))
  (for ((stack-elem (continuation-mark-set->list
 (exn-continuation-marks e) errortrace-key))
#:break (not (void? error-location)))
(let ((s (cadr stack-elem)))
  (when (and (path? s)
 (equal? (normalize-path s) path-norm))
(set! error-location
  (normalize-error-location (cddr stack-elem)
(require-input-port p))
  (unless (void? error-location)
(fprintf (current-error-port) "error at line ~a, column ~a:\n"
 (first error-location)
 (second error-location)))
  (unless (void? error-message)
(fprintf (current-error-port) "~a\n" error-message)
(exit -1))
  (void))



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

Re: [racket-users] DSL to C code generation with symbolic computations en route

2016-04-29 Thread Dmitry Pavlov




RAI seems to be the closest to what I need to do. It has
a DSL with arrays and matrices, it generates C code,
and it even has automatic differentiation, according
to the docs. It is designed for DSP, but probably
can be extended to non-DSP programming. I should
look at it closer.



For the record: here is what I have got with RAI.


#lang racket/base
(require rai/tools
 rai/ai-autodiff
 rai/ai-array
 rai/ai-array-c
 rai/ai-symbolic
 rai/stream-syntax
 rai/stream-lib
 rai/stream-meta)


;; Something defined in Racket with a RAI macro
(define poly
  (ai-lambda-meta (x coefs)
  ((+ ai-add)
   (* ai-mul))
   (begin
 (let ((rcoefs (reverse coefs)))
   (for/fold
   ((acc  (car rcoefs)))
   ((coef (cdr rcoefs)))
 (+ coef (* x acc)))


(module test rai/stream
  ;; Here goes RAI code
  (provide test-fn test-poly test-dotproduct)

  ;; function of two variables
  (define (test-fn x y)
   (/ (sin x) y))

  ;; polynomial of one variable (Horner's rule)
  (define (test-poly x)
(poly x (vector 4 5 6 7)))

  ;; dot product of two 3-vectors
  (define (test-dotproduct xs ys)
(loop (i (n 3))
  ((accu 0))
  ((x xs) (y ys))
  (+ accu (* x y)

(require 'test)



interactions:

;; symbolic derivative of test-fn w.r.t. x
> ((ai-symbolic (ai-deriv test-fn 0)) 'x 'y)

'(/ (cos x) y)

;; symbolic second derivative of test-fn w.r.t. y
> ((ai-symbolic (ai-deriv (ai-deriv test-fn 1) 1)) 'x 'y)

'(- 0 (- 0 (/ (* (sin x) (+ y y)) (* (* y y) (* y y)

;; test-fn in dual numbers for automatic differentiation
> ((ai-symbolic (ai-dual test-fn)) (make-dual 'x0 'dx0) (make-dual 'y0 
'dy0))


(dual '(p_div (sin x0) y0) '(p_sub (p_div (p_mul (cos x0) dx0) y0) 
(p_div (p_mul (sin x0) dy0) (p_mul y0 y0



;; C code for the first derivative
> (display (ai-array-c  (ai-deriv test-fn)))

[...]
static void proc_loop (

for (int t = 0; t < t_endx; t ++) {
struct proc_si * restrict si = (struct proc_si *)([(t^0)&1]);
struct proc_so * restrict so = (struct proc_so *)([(t^1)&1]);
float32_t r0 = p_copy(t);
float32_t r1 = p_copy(t_endx);
float32_t r3 = p_copy(1.0);
float32_t r4 = p_sub(r3,1.0);
so->r6 = p_sub(si->r5,1.0);
float32_t r7 = p_sin(in->x[t]);
float32_t r8 = p_cos(in->x[t]);
float32_t r9 = p_div(r7,in->y[t]);
float32_t r10 = p_div(r8,in->y[t]);
float32_t r11 = p_mul(in->y[t],in->y[t]);
out->r12[t] = p_copy(r10);
}

;; C code for dual numbers (does not quite work)
> (display (ai-array-c (ai-dual test-fn)))

[...]

struct proc_si * restrict si = (struct proc_si *)([(0)&1]);
struct proc_so * restrict so = (struct proc_so *)([(1)&1]);
for (int t = 0; t < t_endx; t ++) {
struct proc_si * restrict si = (struct proc_si *)([(t^0)&1]);
struct proc_so * restrict so = (struct proc_so *)([(t^1)&1]);
float32_t r0 = p_copy(t);
float32_t r1 = p_copy(t_endx);
float32_t r3 = p_copy(1.0);
float32_t r4 = p_sub(r3,1.0);
so->r6 = p_sub(si->r5,1.0);
float32_t r7 = p_sin(in->x[t]);
float32_t r8 = p_cos(in->x[t]);
float32_t r9 = p_div(r7,in->y[t]);
float32_t r10 = p_mul(in->y[t],in->y[t]);
out->r11[t] = p_copy(#(struct:dual r9 0));
}

;; Symbolic representation of the polynomial
> ((ai-symbolic test-poly) 't)
'(+ 4 (* t (+ 5 (* t (+ 6 (* t 7))

;; and its derivative
> ((ai-symbolic (ai-deriv test-poly)) 't)
'(+ (+ 5 (* t (+ 6 (* t 7 (* t (+ (+ 6 (* t 7)) (* t 7

;; and its derivative in C
> (display (ai-array-c (ai-deriv test-poly)))

[...]

for (int t = 0; t < t_endx; t ++) {
struct proc_si * restrict si = (struct proc_si *)([(t^0)&1]);
struct proc_so * restrict so = (struct proc_so *)([(t^1)&1]);
float32_t r0 = p_copy(t);
float32_t r1 = p_copy(t_endx);
float32_t r3 = p_copy(1.0);
float32_t r4 = p_sub(r3,1.0);
so->r6 = p_sub(si->r5,1.0);
float32_t r7 = p_mul(param->x,7.0);
float32_t r8 = p_add(6.0,r7);
float32_t r9 = p_mul(param->x,r8);
float32_t r10 = p_mul(param->x,7.0);
float32_t r11 = p_add(r8,r10);
float32_t r12 = p_add(5.0,r9);
float32_t r13 = p_mul(param->x,r12);
float32_t r14 = p_mul(param->x,r11);
float32_t r15 = p_add(r12,r14);
float32_t r16 = p_add(4.0,r13);
out->r17[t] = p_copy(r15);
}


;; dot product in C
> (display (ai-array-c test-dotproduct))

[...]

for (int t = 0; t < t_endx; t ++) {
struct proc_si * restrict si = (struct proc_si *)([(t^0)&1]);
struct proc_so * restrict so = (struct proc_so *)([(t^1)&1]);
float32_t r0 = p_copy(t);
float32_t r1 = p_copy(t_endx);
float32_t r3 = p_copy(1.0);
float32_t r4 = p_sub(r3,1.0);
so->r6 = 

Re: [racket-users] DSL to C code generation with symbolic computations en route

2016-04-19 Thread Dmitry Pavlov

All,

Thank you very much for the provided references.

Robby, John, Jerzy: thanks for the pointer to Jeff Siskind.
His works on automatic differentiation are very interesting.
I should look at his Stalingrad software.
I did not think about automatic vs symbolic differentiation
before; now I am convinced that I need the former.

(Maybe the latter, too, in specific simple cases,
with racket-cas, thanks Jens Axel)

I agree that nothing that already exists can fullfill
my needs completely (and did not expect that); however,
some projects I can use, either directly or as examples.

For DSL, Honu seems underdone; Magnolisp is richer, but
not complete too (for instance, it does not have vectors).
Lush is nice, but I wanted something statically typed.
Terra is better as it has types. I see no reason
not to look outside of the Racket world for DSL-s
to be implemented in Racket.

For code generation: I am yet to understand whether
Fulmar will actually help (it seems to me now that the
Fulmar code itself is supposed to be generated).
Nanopass seems great, thanks again Jens Axel.

Konrad, Neil: I think completely the same way as you do.
It is just that I am not quite advanced in doing new
and fancy Racket stuff, so I am going to be slow.
First I have to focus on one project, and after that,
on general use.

RAI seems to be the closest to what I need to do. It has
a DSL with arrays and matrices, it generates C code,
and it even has automatic differentiation, according
to the docs. It is designed for DSP, but probably
can be extended to non-DSP programming. I should
look at it closer.


Regards,

Dmitry

--
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] DSL to C code generation with symbolic computations en route

2016-04-18 Thread Dmitry Pavlov

Dear Racketeers,


I, as a programmer in the area of numerics, just evolved to the state
where the following task seem reasonable to work on:

- I need to take (or invent) some DSL for numerical computations.
All I need is: variables and functions, vectors, loops,
arithmetics on numbers and vectors, sin/cos/log/expt and friends,
and some very trivial linear algebra (3x3 matrices basically).

- I need to wrote equations in this DSL and convert them to high-speed
C. While Racket's JIT does a great job, it does lack things that
modern C compilers have, like OpenMP, SSE/AVX instructions,
restricted pointers and such. Even without all this, C code is
1.5x-2x faster according to my experience.

- I need to take derivatives of equations that I wrote in my DSL,
symbolically, and have them converted to C too.


I suspect I am not the only one who wants that.
There must be some work already done.
What would you advise to start with?


A quick search gave me the following:

Honu  https://docs.racket-lang.org/honu/
Magnolisp http://magnolisp.github.io/
RAI   http://zwizwa.be/rai/

What do you think is the most appropriate for the task?
Is there anything else?


Many thanks in advance


Regards,

Dmitry

--
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 cite Racket in a journal paper?

2015-12-20 Thread Dmitry Pavlov

Matthias, Jay,

Thank you for your answers. I will insert the references that you have 
given.



Regards,

Dmitry


On 12/20/2015 10:00 PM, Matthias Felleisen wrote:

Strictly in addition to what Jay says:

Speaking as an EIC of a Journal rather than a Racketeer, I would add a bib
entry or a footnote with a URL to the Racket web site.

Some journals accept URLs as bib entries; others don’t have a standard
yet. My personal preference is to place URLs into footnotes on the word
when it first appears in the paper proper (not abstract).

Put negatively, I have also desk-rejected papers that exclusively use
URLs ad bib entries :-)

— Matthias





On Dec 20, 2015, at 7:05 AM, Jay McCarthy <jay.mccar...@gmail.com> wrote:

Hi Dmitry,

This page describes what you should do:

http://racket-lang.org/tr/ > http://racket-lang.org/tr1/

On Sun, Dec 20, 2015 at 5:52 AM, Dmitry Pavlov <dpav...@ipa.nw.ru> wrote:

Hello,

I am writing a paper for a scientific journal. The results that I am
presenting there were obtained mostly in Racket. What is the best way to
give credit to Racket in references? Is there a specific paper I can
reference, or just link the website?

If specifics matter: I am heavily using core Racket, DrRacket, lexer and
parser, FFI, numerics, little GUI, relatively simple macros, have my own
#lang. I am not using Typed Racket, fancy macros, unit testing, scribble.


Best regards,

Dmitry

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



--
Jay McCarthy
Associate Professor
PLT @ CS @ UMass Lowell
http://jeapostrophe.github.io

   "Wherefore, be not weary in well-doing,
  for ye are laying the foundation of a great work.
And out of small things proceedeth that which is great."
  - D 64:33

--
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] How to cite Racket in a journal paper?

2015-12-20 Thread Dmitry Pavlov

Hello,

I am writing a paper for a scientific journal. The results that I am 
presenting there were obtained mostly in Racket. What is the best way to 
give credit to Racket in references? Is there a specific paper I can 
reference, or just link the website?


If specifics matter: I am heavily using core Racket, DrRacket, lexer and 
parser, FFI, numerics, little GUI, relatively simple macros, have my own 
#lang. I am not using Typed Racket, fancy macros, unit testing, scribble.



Best regards,

Dmitry

--
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] pasteboard% applications

2015-12-05 Thread Dmitry Pavlov




Does anyone have an application using pasteboard%?  I want to try one, and I’d 
love to see an example.


A (bit underdone) spreadsheed editor using pasteboard% :

https://github.com/kugelblitz/spreadsheet-editor

Available in Racket via raco pkg install spreadsheet-editor


Regards,

Dmitry

--
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] What has happened to extflonum support in 32-bit nightly builds?

2015-11-17 Thread Dmitry Pavlov

Matthew,

On 11/13/2015 06:25 PM, Matthew Flatt wrote:

At Thu, 12 Nov 2015 19:11:28 +0300, Dmitry Pavlov wrote:



The more interesting thing is that the 'longdouble.dll' is not put
into the runtime directory by 64-bit Racket, too. Still, the 64-bit
program works without any additional effort.


Oops, sorry, I just checked again, the 64-bit Racket fails too.


I think you'll need to call scheme_set_dll_path(), which should be
exported by the libracket DLL, but it isn't currently declared in
"scheme.h".

   __declspec(dllimport) void scheme_set_dll_path(wchar_t *s);

and provide the path containing "longdouble.dll".


Thanks, that has helped for 32-bit program.


This should be: that has helped for both 32-bit and 64-bit programs.


I've pushed a repair for this problem. The `--runtime` flags was simply
not copying over the DLLs as intended.

I also added a declaration and documentation for scheme_set_dll_path().


Thank you Matthew, it all works like a charm now.

I do this before scheme_main_stack_setup:

  {
wchar_t path[100];

mbstowcs(path, ".\\runtime\\lib", sizeof(path));
scheme_set_dll_path(path);
  }

And this after scheme_basic_env:

  scheme_set_exec_cmd(argv[0]);


It even works when I run the program not from the
directory where the program is located. It somehow
guesses to look for the ".\\runtime\\lib" inside
the directory of argv[0], which is nice.

Best regards,

Dmitry

--
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] embedded Racket + runtime paths = ?

2015-11-17 Thread Dmitry Pavlov

Matthew

On 11/17/2015 03:50 PM, Matthew Flatt wrote:

I found another place where case-normalization of paths was not handled
correctly.

Your example now works for me with a snapshot build. Can you try the
latest?


Yes the latest build works! Thank you very much.
The case can be finally closed, I think.

Best regards,

Dmitry

--
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] embedded Racket + runtime paths = ?

2015-11-15 Thread Dmitry Pavlov

Matthew,


[...] So, if the immediate
repair doesn't solve the problem for you, a follow-up change might.


[...]
Is it e3d78e4, or it is to be done yet?


Yes, it's e3d78e4.



I hate to tell you this, but the error still remains in the
latest nightly build, Windows i386:


>racket
Welcome to Racket v6.3.0.3.
> (require setup/dirs)
> (get-build-stamp)
"20151115-e3d78e4"
> (exit)

>raco ctool --c-mods src/base.c ++lib my-lib/my-lib-module --runtime 
./runtime
copy-and-patch-binaries: not enough room in executable for revised 
#rx#"rUnTiMe-paths[)]" table

  context...:
   C:\Program Files\Racket\collects\compiler\distribute.rkt:385:4: loop
   C:\Program Files\Racket\collects\compiler\distribute.rkt:18:2: 
assemble-distribution11
   C:\Program 
Files\Racket\share\pkgs\cext-lib\compiler\commands\ctool.rkt: [running body]

   C:\Program Files\Racket\collects\raco\raco.rkt: [running body]
   C:\Program Files\Racket\collects\raco\main.rkt: [running body]


Please let me know if I can help by sending more information.


Regards,

Dmitry

--
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] embedded Racket + runtime paths = ?

2015-11-15 Thread Dmitry Pavlov

Matthew,

On 11/13/2015 06:33 PM, Matthew Flatt wrote:

I've pushed a change that may solve this problem.

The change was to the way that `--runtime` determines a shared path
prefix among runtime files, so that it can copy them to a new place but
keep relative paths intact. On Windows, the paths being compared were
sometimes normalized with `normal-case-path` and sometimes not, so the
shared prefix could end up being empty (which means that the files put
in deeply nested directories).

There's still a long-standing problem that computing a shared prefix
doesn't make sense when files are drawn from different effective roots
(e.g., a package in installation scope versus a package in user scope,
or a package versus the current directory). Fortunately, the package
system now gives me to tools that I need to solve this problem; I plan
to try further refinements in the next few days. So, if the immediate
repair doesn't solve the problem for you, a follow-up change might.


I just tried the nightly build 20151113-6343ca0, Win32.
Unfortunately, the error remains.

copy-and-patch-binaries: not enough room in executable for revised 
#rx#"rUnTiMe-paths[)]" table

  context...:
   C:\Program Files\Racket\collects\compiler\distribute.rkt:385:4: loop
   C:\Program Files\Racket\collects\compiler\distribute.rkt:18:2: 
assemble-distribution11
   C:\Program 
Files\Racket\share\pkgs\cext-lib\compiler\commands\ctool.rkt: [running body]

   C:\Program Files\Racket\collects\raco\raco.rkt: [running body]
   C:\Program Files\Racket\collects\raco\main.rkt: [running body]

I will check again after the follow-up change that you tell about.
Is it e3d78e4, or it is to be done yet?

Just so you know: it is not urgent for me right now, I actually
have a work-around that just uses less number of runtime paths,
which ctool handles OK. But I may have more runtime paths in the future.


Best regards,

Dmitry

--
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] What has happened to extflonum support in 32-bit nightly builds?

2015-11-12 Thread Dmitry Pavlov

Matthew,



unsafe-extfllong_double_mult: unsupported on this platform

FWIW, my actual program is a C program that uses a Racket library
obtained with raco ctool. I can provide you more details and a
reproducible example if the above is not enough to hunt down
the cause.


I think the problem is that "longdouble.dll" is not found by Racket as
embedded in your C program. As I recall, you're using some new support
to gather DLLs needed for an embedding, so probably "longdouble.dll" is
gathered into the right directory, but Racket isn't looking there when
trying to load it.


In fact, longdouble.dll is not being put into the "runtime" directory
by raco ctool. All the other relevant libs (libeay32, libgmp-10,
libmpfr-4, ssleay32) are there in the
"runtime\lib\plt\generic\exts\ert\r2\Program Files\Racket\lib\"
subdirectory.

One funny thing is that this particular compiled program actually
does not use extflonums during execution. racket/extflonum is
(require)-d for some macros and functions, but they are not called.

Maybe not putting 'longdouble.dll' there was a right decision
in this case. Or it was not, because how the (eval)-aware
compiler can know which functions are going to be called and which
are not. I am not sure.

The more interesting thing is that the 'longdouble.dll' is not put
into the runtime directory by 64-bit Racket, too. Still, the 64-bit
program works without any additional effort.



I think you'll need to call scheme_set_dll_path(), which should be
exported by the libracket DLL, but it isn't currently declared in
"scheme.h".

  __declspec(dllimport) void scheme_set_dll_path(wchar_t *s);

and provide the path containing "longdouble.dll".


Thanks, that has helped for 32-bit program.



Regards,

Dmitry

--
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] What has happened to extflonum support in 32-bit nightly builds?

2015-11-12 Thread Dmitry Pavlov



The more interesting thing is that the 'longdouble.dll' is not put
into the runtime directory by 64-bit Racket, too. Still, the 64-bit
program works without any additional effort.


Oops, sorry, I just checked again, the 64-bit Racket fails too.


I think you'll need to call scheme_set_dll_path(), which should be
exported by the libracket DLL, but it isn't currently declared in
"scheme.h".

  __declspec(dllimport) void scheme_set_dll_path(wchar_t *s);

and provide the path containing "longdouble.dll".


Thanks, that has helped for 32-bit program.


This should be: that has helped for both 32-bit and 64-bit programs.


Anyway: why not have Racket put longdouble.dll into the runtime
directory, as it does with the others (libmpfr etc)?
It would make things simpler.


Best regards,

Dmitry

--
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] crash in nightly build

2015-11-11 Thread Dmitry Pavlov

Matthew,

More than a week has passed since I updated my
installation of Racket. Good news: no crashes
since the update.

Most probably the bug that you fixed was causing the crash.

Best regards,

Dmitry



On 10/31/2015 06:23 AM, Dmitry Pavlov wrote:

Matthew,

Before upgrading to the version when you fixed this
(or possibly other) crash, I have tried for a long time
to catch it under gdb or rr (Sam, thanks for the pointer to rr).

Unfortunately, the program has never crashed under gdb or rr.
I do not know why. I ran it many times, and it works
like a Swiss watch.

So I am going to upgrade the nightly build and let you know
if the crash happens with it (not under gdb or rr). I hope that
the bug you fixed is relevant to the crash, and then I should not see
it again.

My memory use often is in the interval 256-300 MB. And of course
a lot of minor GC-s are happening. I am not sure about the condition
with the finalizer:
  - whether it is necessary for the crash,
  - whether the crash happens right after the creation of finalizer
or in the future,
  - whether my program actually creates finalizers after initialization.
No code is suddenly called for the first time near the time of the
crash. There is some DB access and some file system access, though.


Anyway, I will install the latest nightly build and see how it goes.

Best regards,

Dmitry


On 10/16/2015 01:16 AM, Matthew Flatt wrote:

I've just stumbled across a subtle and difficult-to-provoke GC bug
while testing new changes to the GC. The problem was introduced in
commit 50df879e or so (September 10), so I think the timing of the
change is consistent with your problem.

For this bug to be relevant, your program would need to run a minor
collection when memory use is in the neighborhood of 256MB to 300MB
(which is not uncommon for 64-bit programs).

The specific crash I can see also involves allocation a finalizer
shortly before the GC, but the creation of a finalizer can be triggered
in many ways, such as calling a bit of code for the first time so that
it gets JIT-compiled.

At Thu, 15 Oct 2015 11:56:21 +0300, Dmitry Pavlov wrote:

Matthew,


It seems that I have lost my grip on the crash.
It has not happened for almost a week---neither with the version
that I build myself, nor with the nightly build where I definitely
saw it. I did not update Racket during this time.
I did not do anything else. I have no idea why it is gone. Sorry.


Oops, it just crashed again, 5+ hours of running.
I will re-run in under gdb. There is no guarantee, though,
that it will crash this time.

By the way, I input "handle SIGSEGV nostop noprint" into gdb prior
to running, to get rid of gdb's complaints about Racket VM's way of
doing things. Am I correct that this should not hide the actual crash?

Best regards,

Dmitry

--
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] embedded Racket + runtime paths = ?

2015-11-05 Thread Dmitry Pavlov

Matthew,

I am reviving this 6-week-old discussion about
raco and runtime paths.

That time, I did not go through with it on Windows.
In my Windows build, I used raco ctool without the --runtime
option, leaving the library tied to absolute paths in the system.

Now I am willing to accomplish the self-contained build.

Here is what stops me:

raco ctool --c-mods src/base.c ++lib racket/base ++lib mylib/my-lib 
--runtime ./runtime


copy-and-patch-binaries: not enough room in executable for revised 
#rx#"rUnTiMe-paths[)]" table

  context...:
   C:\Program Files\Racket\collects\compiler\distribute.rkt:383:4: loop
   C:\Program Files\Racket\collects\compiler\distribute.rkt:18:2: 
assemble-distribution11
   C:\Program 
Files\Racket\share\pkgs\cext-lib\compiler\commands\ctool.rkt: [running body]

   C:\Program Files\Racket\collects\raco\raco.rkt: [running body]
   C:\Program Files\Racket\collects\raco\main.rkt: [running body]

I use the latest nightly build from Utah.
Without the --runtime option, it works.
On Linux, it works with --runtime or without.
All the other issues raised in this old thread (linking etc.) were
resolved by you 6 weeks ago.


I recall that I had that "not enough room in executable" problem
more than a year ago with raco distribute, and you advised to put
some extra dots to the #"." string in
"collects/compiler/embed.rkt" to remedy it.
However, later you reworked that module so that there
is no such string there anymore, so I do not know what to do.

Regards,

Dmitry



On 09/21/2015 08:13 AM, Dmitry Pavlov wrote:




I just tried the 32-bit Utah snapshot and 32-bit C app -- build OK,
but the app crashed right on scheme_main_setup with zero pointer
access. It did not even enter my "run" function.


My initial guess is that it's related to thread-local storage and
missing instructions in "Inside". I'll look into it.


I see that the instructions to use scheme_register_tls_space() for
32-bit Windows are there after all (but easy to overlook). Are you
doing that already?


Oh, I overlooked that setting indeed! Now it works at least
with the Utah 32-bit build, thanks Matthew.



Regards,

Dmitry


--
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] What has happened to extflonum support in 32-bit nightly builds?

2015-10-31 Thread Dmitry Pavlov



Moreover: I just built Racket from github source on 32-bit Linux with
--enable-extflonum switch to ./configure, and the build version
somehow misses the extflonums:


Actually, not from the github source, but from the snapshot "source +
built packages". I guess it should not matter, though.

Regards,

Dmitry

--
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] What has happened to extflonum support in 32-bit nightly builds?

2015-10-31 Thread Dmitry Pavlov

Hello,

I vaguely remember that extflonum support was supposed to be turned
off by default in 32-bit Linux releases. OK. But current 32-bit Windows
nightly builds do not provide it either. I did not notice when they
stopped to provide it.

Moreover: I just built Racket from github source on 32-bit Linux with
--enable-extflonum switch to ./configure, and the build version
somehow misses the extflonums:

 extfl+: unsupported on this platform

I suppose that maybe something went wrong in the build scripts
and/or macros.


Regards,

Dmitry

--
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] crash in nightly build

2015-10-30 Thread Dmitry Pavlov

Matthew,

Before upgrading to the version when you fixed this
(or possibly other) crash, I have tried for a long time
to catch it under gdb or rr (Sam, thanks for the pointer to rr).

Unfortunately, the program has never crashed under gdb or rr.
I do not know why. I ran it many times, and it works
like a Swiss watch.

So I am going to upgrade the nightly build and let you know
if the crash happens with it (not under gdb or rr). I hope that
the bug you fixed is relevant to the crash, and then I should not see
it again.

My memory use often is in the interval 256-300 MB. And of course
a lot of minor GC-s are happening. I am not sure about the condition
with the finalizer:
 - whether it is necessary for the crash,
 - whether the crash happens right after the creation of finalizer
or in the future,
 - whether my program actually creates finalizers after initialization.
No code is suddenly called for the first time near the time of the 
crash. There is some DB access and some file system access, though.



Anyway, I will install the latest nightly build and see how it goes.

Best regards,

Dmitry


On 10/16/2015 01:16 AM, Matthew Flatt wrote:

I've just stumbled across a subtle and difficult-to-provoke GC bug
while testing new changes to the GC. The problem was introduced in
commit 50df879e or so (September 10), so I think the timing of the
change is consistent with your problem.

For this bug to be relevant, your program would need to run a minor
collection when memory use is in the neighborhood of 256MB to 300MB
(which is not uncommon for 64-bit programs).

The specific crash I can see also involves allocation a finalizer
shortly before the GC, but the creation of a finalizer can be triggered
in many ways, such as calling a bit of code for the first time so that
it gets JIT-compiled.

At Thu, 15 Oct 2015 11:56:21 +0300, Dmitry Pavlov wrote:

Matthew,


It seems that I have lost my grip on the crash.
It has not happened for almost a week---neither with the version
that I build myself, nor with the nightly build where I definitely
saw it. I did not update Racket during this time.
I did not do anything else. I have no idea why it is gone. Sorry.


Oops, it just crashed again, 5+ hours of running.
I will re-run in under gdb. There is no guarantee, though,
that it will crash this time.

By the way, I input "handle SIGSEGV nostop noprint" into gdb prior
to running, to get rid of gdb's complaints about Racket VM's way of
doing things. Am I correct that this should not hide the actual crash?

Best regards,

Dmitry

--
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] crash in nightly build

2015-10-05 Thread Dmitry Pavlov

Matthew,

Sorry I am a bit late on this. It is good to know that you keep
track on crash reports even as vague as mine. Here is an update:

-- My crash remains with the nightly build that I installed on Saturday 
(Oct 3);

-- I do not use places;
-- I do not use any new advanced macro facilities (not directly at least);
-- On the previous build, I tried fixing AGE_GEN_0_TO_GEN_HALF to 1 as
you suggested. It did not provoke faster crash.

I have not yet tried your rewind-gc branch.

I am going to get you a stack trace.
Am I correct that in order to get the stack trace, I have to rebuild
Racket with -G and run it in gdb?


Here is another interesting thing that I was able to notice.
As soon as I purged the "compiled" directories from the code tree,
the crashes ceased. I did several consecutive successful runs.
I ran just "racket myprogram", without "raco make" or DrRacket.
Then I executed "raco make myprogram" -- and the very next run
has crashed after ~7h of running.

How do you think, does it make sense that stored bytecode can
cause the crash or is it just a coincidence?

Best regards,

Dmitry


On 10/03/2015 03:27 PM, Matthew Flatt wrote:

I imagine that the "rewind-gc" branch was no help at all. At the time
of your post, there were several open crash reports; I've now resolved
all of them except yours, and none of the others had to do with GC
changes. (One was related to the new macro system, and two were old
bugs in places.)

If you can get any sort of crash report with a stack trace, that
information is often enough for me to either track down the problem or
at least say something about what parts of the example may be relevant.

Thanks,
Matthew

At Mon, 21 Sep 2015 00:08:43 +0300, Dmitry Pavlov wrote:

Hello,

I was just able to discover that my program crashes on the
nightly build 6.2.900.17, on Linux. The program has a heavy portion
of math, double and extended unsafe ops, and accesses multiple
low-level libraries. It has crashed after 4 hours of running,
while doing just the same that it had been doing for those
4 hours.

SIGSEGV MAPERR si_code 1 fault on addr 0x7f9f0d16a008

The previous version of Racket that I used for a long time
(and saw no crashes with it) is 6.2.0.3.

Before I go into deeper analysis by trial and error, maybe
the developers (I guess it would be Matthew) could give any
insight on what has been done since 6.2.0.3 that could result
in the crash? How to stress the VM to wait less till the crash
occurs?


Best regards,

Dmitry

--
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] embedded Racket + runtime paths = ?

2015-09-20 Thread Dmitry Pavlov




I just tried the 32-bit Utah snapshot and 32-bit C app -- build OK,
but the app crashed right on scheme_main_setup with zero pointer
access. It did not even enter my "run" function.


My initial guess is that it's related to thread-local storage and
missing instructions in "Inside". I'll look into it.


I see that the instructions to use scheme_register_tls_space() for
32-bit Windows are there after all (but easy to overlook). Are you
doing that already?


Oh, I overlooked that setting indeed! Now it works at least
with the Utah 32-bit build, thanks Matthew.



Regards,

Dmitry

--
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] embedded Racket + runtime paths = ?

2015-09-20 Thread Dmitry Pavlov

Matthew,



I've added a `--runtime ` argument to `raco ctool --cmods`, which
gathers runtime files into  and makes the embedded modules refer
to them in  (which is expected to be relative to the executable,
but see also the `--runtime-access` option).

The embedding executable must call scheme_set_exec_cmd() to set the
result of `(find-system-path 'exec-file)` so that runtime files can be
found in  relative to the executable.


Great! I just tested it on Linux with nightly build 6dfc20d.

On Windows, though, I ran into a problem when linking my app
with pre-built libracket3m_9yy8mp.lib :

error LNK2001: unresolved external symbol __imp_scheme_get_mz_setjmp

That is the only unresolved symbol. All the others were gone after
I added libracket3m_9yy8mp.lib to the project.
Do you have an idea how I can fix that one?

Best regards,

Dmitry

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


  1   2   >