Re: [racket-users] Layout + styling in racket/gui

2020-07-07 Thread WarGrey Gyoudmon Ju
On Tue, Jul 7, 2020 at 6:18 AM Travis Kiefer  wrote:

> Jens,
>
> Thank you for the example links. The spreadsheet example gets closer to
> the right direction of a non-trivial example. What's missing from these is
> the ability to add styles to the elements... Background colors, gradients,
> box shadow, border around a container element, left align, right align, et
> cetera.
>
>
Hi, Travis.

I have a CSS package aimed at this, and I used it to build my GUI
Application 4 years ago.
But this approach requires application authors to write their own GUI
components with Racket snip%.

I am going to add docs for that package, which is just an engine
implementation of CSS 3.0 specs,
and it is really far away from the real world GUI applications.

This field still remains to be further researched,
I have a vague plan to make a GUI framework based on GPU.
This plan sounds too big to be talked about here at the moment.

-- 
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/CAFp0D56qf0ZKgncuZiM-T3p6NFErkVWG8YfW6K6hzw_FETdwXA%40mail.gmail.com.


[racket-users] Re: [racket][scribble] hyperlink problem in generated PDF

2020-06-22 Thread WarGrey Gyoudmon Ju
Sorry, cite links have the same problem too.

On Tue, Jun 23, 2020 at 5:27 AM WarGrey Gyoudmon Ju 
wrote:

> Greetings.
>
> It seems that Scribble generated PDFs have troubles in dealing with
> hyperlinks produced by `deftech` and `elemtag`. The anchors of the targets
> are not those elements themselves but sections containing them. In other
> words, when readers click the link, it always jumps to the containing
> section instead of the target no matter if the target is on the same page
> or not.
>
> The attachment is a simple example generated by DrRacket.
>
> Meanwhile cite links and footnotes work well.
>
> Is it the problem of the `hyperref` package? If so, what should I do?
> Thanks in advance.
>

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


[racket-users] [racket][scribble] hyperlink problem in generated PDF

2020-06-22 Thread WarGrey Gyoudmon Ju
Greetings.

It seems that Scribble generated PDFs have troubles in dealing with
hyperlinks produced by `deftech` and `elemtag`. The anchors of the targets
are not those elements themselves but sections containing them. In other
words, when readers click the link, it always jumps to the containing
section instead of the target no matter if the target is on the same page
or not.

The attachment is a simple example generated by DrRacket.

Meanwhile cite links and footnotes work well.

Is it the problem of the `hyperref` package? If so, what should I do?
Thanks in advance.

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


pdftex.pdf
Description: Adobe PDF document


Re: [racket-users] Defeating Racket’s separate compilation guarantee

2019-04-24 Thread WarGrey Gyoudmon Ju
Great article, thanks.

I like the logging facility, now I see it is more powerful than I known.

On Thu, Apr 25, 2019 at 6:25 AM Gustavo Massaccesi 
wrote:

> We can extract an feature request from the end of the post:
>
> Make the module that define `set` a cross-phase persistent module, so all
> the phases can share the `set`s.
>
> Gustavo
>
>
>
>
> On Sun, Apr 21, 2019 at 7:41 AM Alexis King  wrote:
>
>> Hello all,
>>
>> I just published a blog post on defeating Racket’s separate compilation
>> guarantee. While I don’t imagine such a thing is actually a good idea, I
>> think the path to getting there is interesting anyway, and it touches lots
>> of different parts of the Racket system. For those who are interested, the
>> blog post is available here:
>>
>>
>> https://lexi-lambda.github.io/blog/2019/04/21/defeating-racket-s-separate-compilation-guarantee/
>>
>> Comments welcome,
>> Alexis
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Generate really large random numbers in Racket

2019-04-01 Thread WarGrey Gyoudmon Ju
Hi, I am writing SSH in pure typed racket,
Generating a big random primes is one of the tasks and I just finished it.

https://github.com/wargrey/lambda-shell/blob/master/ssh/digitama/algorithm/random.rkt
https://github.com/wargrey/lambda-shell/blob/master/ssh/digitama/algorithm/rsa.rkt

Before I write my own routines, I have read the source code of racket/math,
OpenSSH and OpenSSL.
So I think the only security problem is I am not using `crypto-random-bytes

`.

By the way, racket/math may already have been fit you.


On Tue, Apr 2, 2019 at 6:06 AM Alex Harsanyi  wrote:

> You can use `crypto-random-bytes` to generate large random numbers,
> however, that function returns a string of bytes, which you have to combine
> into an integer:
>
> (define 
> 
>  (random-bignum bits)
>   (define 
> 
>  num-bytes (exact-ceiling 
> 
>  (/ 
> 
>  bits 8)))
>   (for/fold 
> 
>  ([result 0])
> ([byte (in-bytes 
> 
>  (crypto-random-bytes 
> 
>  num-bytes))])
> (+ 
> 
>  byte (* 
> 
>  result 256
>
>
> Alex.
>
> On Tuesday, April 2, 2019 at 5:39:46 AM UTC+8, Shaobo He wrote:
>>
>> Thank you for your reply. This is my thought too but I'm not sure if
>> combining multiple random bits break any good properties of random number
>> generators. Sorry I should've mentioned it. I was talking about bounded
>> random numbers.
>>
>> Robby Findler  于2019年4月1日周一 下午3:35写道:
>>
>>> Generate multiples of those and combine them (shifting old ones over
>>> and adding new ones as the lowest digits)?
>>>
>>> I'm not sure of a good way to generate nats uniformly at random where
>>> you don't specify an upper bound, but Neil Toronto suggested something
>>> crazy we used this paper:
>>> http://users.cs.northwestern.edu/~robby/pubs/papers/jfp2017-nfmf.pdf
>>>
>>> Robby
>>>
>>> On Mon, Apr 1, 2019 at 4:31 PM  wrote:
>>> >
>>> > Hello everyone,
>>> >
>>> > It appears that the largest number returned by the random function in
>>> Racket is 4294967087-1 for a good reason. Are there any libraries or simple
>>> approaches to generate a number larger than that?
>>> >
>>> > Thanks,
>>> > Shaobo
>>> >
>>> > --
>>> > 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...@googlegroups.com.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] performance, json

2019-02-22 Thread WarGrey Gyoudmon Ju
I have tried my best to find the "best practice" to do Racket IO.

Here are some tips I found in writing CSV reader:
https://github.com/wargrey/schema/blob/master/digitama/exchange/csv/reader/port.rkt
With a MacBook Pro 15, 2013, it takes 3.5s to read a 70MB file.

I agreed that `read-char` is the first choice, but `peek-char` may be slow
somehow.
Instead, just read the `peek`ing chars and pass it or them as the leading
ones to the parsing routine.
This strategy may require a re-design of your parsing workflow
since every subroutine should accept another input argument and return one
more value.


On Sat, Feb 23, 2019 at 5:34 AM Jon Zeppieri  wrote:

> On a related (but not too related) note: is there an efficient way to skip
> multiple bytes in an input stream? It looks like there are two choices:
>   - You can read the bytes you want to skip, but that implies either
> allocating a useless byte array or keeping one around for this very purpose.
>   - You can use (I think?) port-commit-peeked, bit given the API, it seems
> like that was designed with a particular (and more complicated) use in mind.
>
>
> On Fri, Feb 22, 2019 at 3:35 PM Matthew Flatt  wrote:
>
>> I think the bigger bottleneck is the main parsing loop, which uses
>> `regexp-try-match` even more. Although `regexp-try-match` is
>> convenient, it's much slower than using `peek-char` directly to check
>> for one character. I'll experiment with improvements there.
>>
>> At 22 Feb 2019 13:36:20 -0500, "'John Clements' via Racket Users" wrote:
>> > I’m not that surprised :).
>> >
>> > My guess is that our json reader could be sped up quite a bit. This
>> looks like
>> > the heart of the read-json implementation:
>> >
>> > (define (read-json* who i jsnull)
>> >   ;; Follows the specification (eg, at json.org) -- no extensions.
>> >   ;;
>> >   (define (err fmt . args)
>> > (define-values [l c p] (port-next-location i))
>> > (raise-read-error (format "~a: ~a" who (apply format fmt args))
>> >   (object-name i) l c p #f))
>> >   (define (skip-whitespace) (regexp-match? #px#"^\\s*" i))
>> >   ;;
>> >   ;; Reading a string *could* have been nearly trivial using the racket
>> >   ;; reader, except that it won't handle a "\/"...
>> >   (define (read-string)
>> > (define result (open-output-bytes))
>> > (let loop ()
>> >   (define esc
>> > (let loop ()
>> >   (define c (read-byte i))
>> >   (cond
>> > [(eof-object? c) (err "unterminated string")]
>> > [(= c 34) #f]   ;; 34 = "
>> > [(= c 92) (read-bytes 1 i)] ;; 92 = \
>> > [else (write-byte c result) (loop)])))
>> >   (cond
>> > [(not esc) (bytes->string/utf-8 (get-output-bytes result))]
>> > [(case esc
>> >[(#"b") #"\b"]
>> >[(#"n") #"\n"]
>> >[(#"r") #"\r"]
>> >[(#"f") #"\f"]
>> >[(#"t") #"\t"]
>> >[(#"\\") #"\\"]
>> >[(#"\"") #"\""]
>> >[(#"/") #"/"]
>> >[else #f])
>> >  => (λ (m) (write-bytes m result) (loop))]
>> > [(equal? esc #"u")
>> >  (let* ([e (or (regexp-try-match #px#"^[a-fA-F0-9]{4}" i)
>> >(err "bad string \\u escape"))]
>> > [e (string->number (bytes->string/utf-8 (car e)) 16)])
>> >(define e*
>> >  (if (<= #xD800 e #xDFFF)
>> >  ;; it's the first part of a UTF-16 surrogate pair
>> >  (let* ([e2 (or (regexp-try-match
>> #px#"^u([a-fA-F0-9]{4})"
>> > i)
>> > (err "bad string \\u escape, ~a"
>> >  "missing second half of a UTF16
>> pair"))]
>> > [e2 (string->number (bytes->string/utf-8 (cadr
>> e2))
>> > 16)])
>> >(if (<= #xDC00 e2 #xDFFF)
>> >(+ (arithmetic-shift (- e #xD800) 10) (- e2
>> #xDC00)
>> > #x1)
>> >(err "bad string \\u escape, ~a"
>> > "bad second half of a UTF16 pair")))
>> >  e)) ; single \u escape
>> >(write-string (string (integer->char e*)) result)
>> >(loop))]
>> > [else (err "bad string escape: \"~a\"" esc)])))
>> >   ;;
>> >   (define (read-list what end-rx read-one)
>> > (skip-whitespace)
>> > (if (regexp-try-match end-rx i)
>> > '()
>> > (let loop ([l (list (read-one))])
>> >   (skip-whitespace)
>> >   (cond [(regexp-try-match end-rx i) (reverse l)]
>> > [(regexp-try-match #rx#"^," i) (loop (cons (read-one)
>> l))]
>> > [else (err "error while parsing a json ~a" what)]
>> >   ;;
>> >   (define (read-hash)
>> > (define (read-pair)
>> >   (define k (read-json))
>> >   (unless (string? k) (err "non-string value used for json object
>> key"))
>> >   (skip-whitespace)
>> >   

Re: [racket-users] Seeking a graphviz like, diagramming language for Racket

2017-08-19 Thread WarGrey Gyoudmon Ju
On Sun, Aug 20, 2017 at 1:20 AM, Andrew Gwozdziewycz 
wrote:

> Are you focused more on replacing Graphviz, or a generalized drawing
> and visualization library that could be used to more easily put
> together a Graphviz like tool? I guess they are likely somewhat
> similar goals...


Firstly, I just write it for fun, but also focus on high quality real world
applications
since I do not want to use any software design tools that force me dragging
and clicking.

In untyped racket (but may not in the main distribution), there are a lot
of small packages
that focus on one or more subfields of graph visualization and layout
algorithms. In typed
racket, there also are pict3d, plot, and flomap based images. So I think
they definitely benefit
user-designers and covers lots of everyday usage, but user-developers may
need more
extension abilities since modern applications grow too fast.

Therefore, I am writing a modern design engine for programmers with an
elegant functional interface,
graphviz like tool is one of the applications of this engine, actually it
is likely to be the first one.

For now,
* CSS syntax and its computation model is chosen to style elements and
items;
* New architecture and datatypes is coming soon for
reading/composing/writing image resources.

Also I am glad to write the entire tex system in native Typed Racket,
though it is really a huge
project and therefore a long term plan.

-- 
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] Seeking a graphviz like, diagramming language for Racket

2017-08-19 Thread WarGrey Gyoudmon Ju
I have been working on it, but at very beginning stage and no working code
right now.

The official website of Graphviz  provides lots of papers on the underlying
algorithms,
I also found *Handbook of Graph Drawing and Visualization *is worth reading.

On Fri, Aug 18, 2017 at 6:10 PM, Andrew Gwozdziewycz 
wrote:

> Hi folks,
>
> I've been using graphviz for years for basic network architecture
> diagrams and things, mostly to avoid answering the question of "which
> annoying tool should I use?" Graphviz has limitations for the type of
> stuff I use it for, but I settle for it anyway, since it's a lot less
> frustrating to use a language for laying out relationships than
> clicking and dragging lines connecting things, in an agreed upon
> diagramming tool.
>
> Has anyone started work (or finished work, or even somewhere in
> between?) on a diagramming language that might be, or even eventually
> will be a suitable replacement for performing these types of tasks?
>
> And if not, does anyone have suggestions for getting started with
> layout drawing algorithms suitable for such a thing? I'm fairly sure
> that the pict language will do the heavy lifting work for actually
> drawing on a canvas, and simple layout techniques probably would go
> along way, but getting to know the field a bit might be useful...
>
> Cheers,
>
> Andrew
> --
> http://www.apgwoz.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.
> 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] Printing Quickly

2017-07-25 Thread WarGrey Gyoudmon Ju
On Tue, Jul 25, 2017 at 4:52 PM, George Neuner  wrote:
>
> Having little experience with Racket's drawing library, I can't speak to
> how fast it is.  I do recall someone saying it was (mostly) just a thin
> layer over the native platform library, but even "thin layers" add some
> latency.   Nor do I have any clue as to how clever DrRacket is with its
> drawing.
>

It's true for all other classes that implement the interface control<%>
except the text% and text-field%, the editor infrastructure is completely
implemented in Racket, there *are* some optimizations for speed by, such
as, disabling ligatures. Sometimes I still hope there would be an
alternative to the native text-field controller.

-- 
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] Wrap long text in 2htdp/image

2017-07-22 Thread WarGrey Gyoudmon Ju
Yes, but you must implement it yourself.

This simplest one works for fixed-width font (implemented with pict-lib,
you get the idea):

(define desc
  (lambda [txt size width #:head [head (blank 0 0)] #:style [fstyle null]]
(define {desc0 txt size width fstyle}
  (call-with-current-continuation
   {lambda [return]
 (when (or (< width size) (zero? (string-length txt))) (return
(list (blank 0 0) txt)))
 (define hit (min (string-length txt) (exact-floor (/ width size
 (define hpict (text (substring txt 0 hit) fstyle size))
 (define final (desc0 (substring txt hit) size (- width (pict-width
hpict)) fstyle))
 (list (hc-append hpict (first final)) (second final))}))
(define smart (desc0 txt size width fstyle))
(vl-append head (cond [(zero? (string-length (second smart))) (first
smart)]
  [else (desc (second smart) size width #:head
(first smart) #:style fstyle)]

Once I implemented a more complex one[1] that works for all fonts with the
exponential search algorithm, but it's not efficient.
Now this constructor is re-written with the Pango Layout API[2].

Maybe racket/draw should support text layout interface directly.

[1]bitmap-desc

[2]bitmap-paragraph



On Sun, Jul 23, 2017 at 1:34 AM, kay  wrote:

> When using 2htdp/image to create a text image, is this possible to specify
> a "bounding box" for the image, so that the text could be wrapped to fit
> that box?
>
> E.g., below line:
>
>   (text "This wide, sharp telescopic view reveals galaxies scattered
> beyond the stars of the Milky Way at the northern boundary of the
> high-flying constellation Pegasus. Prominent at the upper right is NGC
> 7331. A mere 50 million light-years away, the large spiral is one of the
> brighter galaxies not included in Charles Messier's famous 18th century
> catalog. The disturbed looking group of galaxies at the lower left is
> well-known as Stephan's Quintet. About 300 million light-years distant, the
> quintet dramatically illustrates a multiple galaxy collision, its powerful,
> ongoing interactions posed for a brief cosmic snapshot. On the sky, the
> quintet and NGC 7331 are separated by about half a degree." 10 "black")
>
>
> creates a super long line text image without wrapping, when I want to
> overlay it on another image, it's mostly useless. I want to specify a
> "size" (aka bounding box) for it so it wraps properly.
>
> Is that possible?
>
> --
> 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] Putting everything in a single monolithic source file

2017-07-21 Thread WarGrey Gyoudmon Ju
If the code is written in Typed Racket, the compilation time will drive you
mad
since every one-byte-modification forces the entire project being
typed-checked...

On Fri, Jul 21, 2017 at 5:07 PM, Erich Rast  wrote:

> I'm using mostly racket-mode in emacs for development and even with helm
> and projectile mode greping info from the source directory is
> cumbersome. So I was thinking about putting my entire project into one
> source file with lots of explicit (module ...) declarations. This
> doesn't break modularity, I'm the only developer, and I can still
> factor out specific modules as packages later.
>
> But I'm  wondering whether this has any other disadvantages e.g. for
> compilation or optimization, or might even break in future?
>
> Best,
>
> Erich
>
> --
> 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] beating java (speed)

2017-07-02 Thread WarGrey Gyoudmon Ju
Yes, I agree with you.

Choosing "unsafe" operations is a tradeoff since Typed FFI is unavailable,
I need a convenient and practical framework.
I am sure, in the future, I will rewrite it without FFI.

images/flomap was a great starting point.

Anyway, it is a longterm plan.


On Sun, Jul 2, 2017 at 8:14 AM, Neil Van Dyke  wrote:

> Any standard pixmap library that is sufficiently fast *without* using
> "unsafe" language is a win.  Pixmap libraries are one of the most prolific
> class of unacceptably buggy code implemented C, and routinely provide
> remote exploit vectors via Web browsers and copied document files, as well
> as finely targeted attacks via email.
>
> I was hoping something like Rust would solve this problem for GNU/Linux,
> of sufficiently good C programming being too difficult in practice.  But
> the Rust language and toolchain now have size, complexity, and security
> issues of their own to address.
>
> Not that I expect GNU/Linux developers to start implementing a significant
> portion of userspace in Racket.  Though I have some idea how it might
> possibly be made to happen, politically, if people were first ready to
> commit skilled person-years to particular technical issues.  In the
> meantime, making linguistically "safe" programs with sufficiently good
> performance is a good direction.  (I'd prefer to mostly save "unsafe" for
> things like numeric-intensive modules that really need whatever boost, and
> that are tractably verifiable.  If we start doing unsafe operations on
> blocks of bytes, for example, without verification, we probably start
> recreating many of the same mistakes we'd make in C.)
>
>

-- 
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] beating java (speed)

2017-07-01 Thread WarGrey Gyoudmon Ju
Hello, did you try remove racket/unsafe/ops?
You do not have to use unsafe operations for fixnum and flonum, Typed
Racket will do it for you.


I am not sure if this is my problem, I found that racket/unsafe/op slows
down my typed bitmap library.
According to the Optimization Coach, FlVector (with unsafe-flvector-ref)
should be faster than (Vectorof Flonum), but I found it's not true.
Another example is unsafe-vector-ref is slower than vector-ref.

On Sat, Jul 1, 2017 at 9:07 PM, 'Shakin Billy' via Racket Users <
racket-users@googlegroups.com> wrote:

> hi,
>
> i've been working a little on project euler problem 501.
> my first attempt is a burte forcce loop.4iw rote it in java und racket and
> found java to be faster by factor 3:
>
> racket
>
> #lang typed/racket
> (require racket/unsafe/ops)
> (require racket/fixnum)
> (require racket/trace)
> ;(require typed/racket/performance-hint)
>
> (: acht-teiler (-> Fixnum Boolean))
> (define (acht-teiler (n : Fixnum))
>   (: loop (-> Fixnum Fixnum Fixnum Fixnum Boolean))
>   (define (loop (i : Fixnum) (count : Fixnum) (quadrat : Fixnum) (steigung
> : Fixnum))
> (cond ((unsafe-fx= quadrat n) #f)
>   ((unsafe-fx> quadrat n) (unsafe-fx= count 3))
>   ((unsafe-fx= (unsafe-fxmodulo n i) 0) (loop (unsafe-fx+ i 1)
> (unsafe-fx+ count 1) (unsafe-fx+ quadrat steigung) (unsafe-fx+ steigung 2)))
>   (else (loop (unsafe-fx+ 1 i) count (unsafe-fx+ quadrat steigung)
> (unsafe-fx+ steigung 2)
>   (loop 2 0 4 5))
>
> (acht-teiler 36)
>
> (: achter (-> Fixnum Fixnum))
> (define (achter (n : Fixnum))
>   (: loop (-> Fixnum Fixnum Fixnum))
>   (define (loop (i : Fixnum) (count : Fixnum))
> (cond ((unsafe-fx= i n) count)
>   ((acht-teiler i) (loop (unsafe-fx+ i 1) (unsafe-fx+ count 1)))
>   (else (loop (unsafe-fx+ i 1) count
>   (loop 2 0))
>
> (time (achter 100))
> ; for 100 = 24, 30, 40, 42, 54, 56, 66, 70, 78 and 88
> ; f(100) = 10, f(1000) = 180 and f(10e6) = 224427
>
> for java:
>
> import java.util.concurrent.Executor;
> import java.util.concurrent.ExecutorService;
> import java.util.concurrent.Executors;
> import java.util.concurrent.TimeUnit;
>
> public class EightDivs  implements Runnable{
>
> public static Object lock = new Object();
> public static long count = 0;
>
> private long low;
> private long high;
>
> public EightDivs(long low, long high){
> this.low = low;
> this.high = high;
> }
>
> public boolean hasEightDivsExact(long a){
> int divs = 0;
> for(long i =1;i<=a;i++){
> if(a % i == 0){
> divs++;
> }
> }
> return divs == 8;
> }
>
> public boolean hasEightDivs(long a){
> int divs = 0;
> for(long i = 2; i*i <= a && divs < 4;i++){
> if(a % i == 0){
> divs++;
> if (i*i == a && divs >= 3){
> return false;
> }
> }
> }
> return divs == 3;
> }
>
> public static void main(String[] args) throws InterruptedException
> {
> ExecutorService ex = Executors.newFixedThreadPool(4);
> long old = 1;
> long start = System.currentTimeMillis();
> //  for(long i = 0L; i<= 1000_000L;i+=100_00){
> //  ex.execute(new EightDivs(old, i));
> System.out.println(old +" low " + i + " high");
> //  old = i;
> //  }
> //  ex.shutdown();
> //  ex.awaitTermination(300, TimeUnit.SECONDS);
> new EightDivs(1, 1000_000).run();
> long end = System.currentTimeMillis();
> System.out.println((end-start)/1000d+" Seconds");
> //  new EightDivs(1, 1000).hasEightDivs(24);
>
> System.out.println(count);
> }
>
> @Override
> public void run() {
> for(long i = low;i if(hasEightDivs(i)){
> //  System.out.println(i);
> synchronized (lock) {
> count++;
> }
> }
> }
> System.out.println(low +" low " + high + " high done");
> }
>
> }
>
>
> --END CODE
>
> java code runs in 4.5 seconds
> racket code takes 12.5 seconds to complete (in cli-mode)
>
> i typed racket and used unsafe operations. some perfomance hints from the
> guide don't seem to apply since i already tyyped racket.
> the optimization coach hints to use define-inline but it seems to be
> available 

Re: [racket-users] Convert mouse coordinates in mouse-event% to window coordinates? And also for snip%...

2017-05-23 Thread WarGrey Gyoudmon Ju
Hi Rast

the mouse event object of editor% and snip% is always the one passed to the
on-event method of editor-canvas% (that's why event handlers of snip% have
lots of extra arguments to provide you the location information,
racket/snip do the computing for you). When it is used with a snip%
instance directly, you have to check the docs to see the proper way to use
it correctly. Another thing you should take care is that, the event object
itself is not able to tell you the snip%s' enter and leave stats.

A1 & A2: You have get-top-level-windows and get-current-mouse-state. (But
the Question 1 is not necessary for your requirements here).
A3: You have get-snip-location, local-to-global, and client->screen.


On Tue, May 23, 2017 at 10:24 PM, Erich Rast  wrote:

> Hi,
>
> For me personally, coordinates are probably the most unintuitive aspect
> of Racket's GUI management. The problem comes up again and again, and I
> never get it right, so maybe someone can clarify this once and for all.
>
> I have a mouse-event% in on-event of a snip% and would like to display
> a floating frame% just below the mouse.
>
> Question 1: What is the right way to obtain the window in a potentially
> nested hierarchy of editors? I'm currently using:
>
> (define top-window (and-let* ((canvas (get-canvas))
>(top (send canvas get-top-level-window)))
>   top))
>
> is that correct?
>
> Question 2: How do I obtain the right coordinates for the frame% that I
> would like to show below the mouse?
>
> I assume it has something to do with top-window above, but how do I
> convert from the coordinates of the mouse-event to the 'right'
> coordinates? Currently, the frame% appears offset about 20 to 20 pixels
> below the top-window's top-left corner and not at all where the mouse
> is located.
>
> Are the mouse-event coordinates relative to the editor? Or relative to
> the snip within the editor? How do I convert them?
>
> Question 3: Suppose I want to do the same with a snip% displayed in a
> text% with one editor-canvas%, i.e., show a floating window just below
> the snip%. Use cases: tooltips, spell corrections, etc.
>
> How do I do that?
>
> Thanks a lot in advance!
>
> Best,
>
> Erich
>
>
>
> --
> 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] Speeding up graphics / moving away from 2htdp/image

2017-05-02 Thread WarGrey Gyoudmon Ju
On Tue, May 2, 2017 at 8:02 PM, Daniel Prager 
wrote:

> Hi Ju
>
> Interesting results. Did you run the Contract Profiler tool? [
> http://docs.racket-lang.org/contract-profile/]
>
> I think it's fairly well understood that the contract-induced performance
> costs across the typed / untyped boundary can be severe.
>

No, I didn't run the Contract Profiler tool.

I just wanted to optimize it, the weirdest thing I found is, the total time
is much larger then the sum of the in-function `time`s, I guess all bitmaps
are checked one by one by the contract system, they are all objects.

Last time I mentioned the flomap, I said "You need to convert the flomap
struct into a bitmap% instance when drawing", the main reason is that
nobody seems to maintain the images-lib, and it's Bitmap% is not the
standard one since it exists before typed class is available, therefore the
`flomap->bitmap` will simply fail due to the contract error. There is a
pull request for it, but still has not been merged since 2015. [
https://github.com/racket/images/pull/2]



> BTW: At the back of my mind is the thought that the performance one could
> achieve on these kinds of benchmarks would go up ridiculously by pushing
> the work to a GPU.
>

Yeah, some games shipped with the main distribution are written in
racket-wrapped OpenGL. Despite the totally different APIs, you can try real
time rendering algorithms without worrying about the performance. In fact,
I am hesitating too, I have already finished the computational model of the
CSS engine, but not sure whether the GUI part should be implemented with
OpenGL or not. Designing application as a Game UI developer is fun, but
meanwhile I do not have much time to do that.

-- 
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] Speeding up graphics / moving away from 2htdp/image

2017-05-02 Thread WarGrey Gyoudmon Ju
Hello, I found an interesting thing.

My conclusion was totally wrong since your example are written in Untyped
Racket, the generated contracts eat all the seconds unconsciously.

Timing your example in Typed Racket with my functional bitmap combiners:

no optimizing, generating all 2500 bitmaps on the fly:
bitmap-*-append...
cpu time: 386 real time: 387 gc time: 20
bitmap-table...
cpu time: 381 real time: 381 gc time: 10

with memorizing (only 2 distinguishable bitmaps are generated):
bitmap-*-append...
cpu time: 85 real time: 85 gc time: 0
bitmap-table...
cpu time: 93 real time: 94 gc time: 23

Still slower than pict, but as a raster graphics API, it does a great job!

On Sat, Apr 29, 2017 at 11:19 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com
> wrote:

>
>
> On Sat, Apr 29, 2017 at 5:21 AM, Daniel Prager <daniel.a.pra...@gmail.com>
> wrote:
>
>> On Sat, Apr 29, 2017 at 2:10 AM, WarGrey Gyoudmon Ju <
>> juzhenli...@gmail.com> wrote:
>>
>>> Hello, I think the main reason that pict is faster than 2htdp/image is,
>>> the pict is implemented with struct while the 2htdp/image is implemented
>>> with class, the speed of rendering is just as fast/slow as each other, but
>>> manipulation on class is much heavier than on struct when combining large
>>> numbers of shapes. Maybe you want to check the code of `table` in pict-lib,
>>> it is a good example to place shapes into grids in a functional way.
>>>
>>
>> Interesting. I'd also note that unlike pict 2htdp/image doesn't provide a
>> way to draw direct to dc, necessitating going via bitmaps when using it in
>> conjunction with racket/gui.
>>
>
> Actually, this is not the case, every 2htdp/image shape is a subclass of
> snip%(see the `draw` method of snip%), though you have to compute another 9
> arguments...
>
> I remembered some points that old conversations had suggested:
> 1. 2htdp/image is not efficient enough for building real world gui
> application, racket/draw should be used instead.
> 2. When drawing large amount of shapes, the cost of getting into and out
> the drawing context is critical.
> 3. typed racket is helpful even for real time rendering, say, perlin
> noise, almost as fast as java, (but I did not see the direct link between
> your work and real time rendering.)
>
> Good luck for you.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Speeding up graphics / moving away from 2htdp/image

2017-04-28 Thread WarGrey Gyoudmon Ju
On Sat, Apr 29, 2017 at 5:21 AM, Daniel Prager <daniel.a.pra...@gmail.com>
wrote:

> On Sat, Apr 29, 2017 at 2:10 AM, WarGrey Gyoudmon Ju <
> juzhenli...@gmail.com> wrote:
>
>> Hello, I think the main reason that pict is faster than 2htdp/image is,
>> the pict is implemented with struct while the 2htdp/image is implemented
>> with class, the speed of rendering is just as fast/slow as each other, but
>> manipulation on class is much heavier than on struct when combining large
>> numbers of shapes. Maybe you want to check the code of `table` in pict-lib,
>> it is a good example to place shapes into grids in a functional way.
>>
>
> Interesting. I'd also note that unlike pict 2htdp/image doesn't provide a
> way to draw direct to dc, necessitating going via bitmaps when using it in
> conjunction with racket/gui.
>

Actually, this is not the case, every 2htdp/image shape is a subclass of
snip%(see the `draw` method of snip%), though you have to compute another 9
arguments...

I remembered some points that old conversations had suggested:
1. 2htdp/image is not efficient enough for building real world gui
application, racket/draw should be used instead.
2. When drawing large amount of shapes, the cost of getting into and out
the drawing context is critical.
3. typed racket is helpful even for real time rendering, say, perlin noise,
almost as fast as java, (but I did not see the direct link between your
work and real time rendering.)

Good luck for you.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Speeding up graphics / moving away from 2htdp/image

2017-04-28 Thread WarGrey Gyoudmon Ju
Hello, I think the main reason that pict is faster than 2htdp/image is, the
pict is implemented with struct while the 2htdp/image is implemented with
class, the speed of rendering is just as fast/slow as each other, but
manipulation on class is much heavier than on struct when combining large
numbers of shapes. Maybe you want to check the code of `table` in pict-lib,
it is a good example to place shapes into grids in a functional way.

I tested your example with my functional bitmap APIs (with arguments
memorized, and it only creates one bitmap% when combining a list of
shapes), as expected it is too slow(<3s, without memorizing it's <6s) to
stand with, but it also indicates that half or less time used is not
creating or drawing single primitive shapes, but every primitive shape is
rendered duplicately whenever its combining shape is rendering. So the
issue is, to find a strategy to call `freeze` at a reasonable level of
combined shapes.

One reason that you may have to write your own combiner(here the term
should be "layout") is, `freeze` can make a big shape, but it cannot avoid
the duplicate rendering since it actually do the drawing. So your combiner
would focus on providing the position and size information for dc to `draw`
or `copy` and/or `rotate/flip`. Sounds hard to do it with fewer bugs.

On Fri, Apr 28, 2017 at 9:32 PM, Daniel Prager 
wrote:

> Thanks Hendrik & Alex
>
> Hendrik:
>
> What you're suggesting sounds to me a lot like what the pict library
> already does. Switching to pict would seem to give a good speed-up, but
> perhaps it's possible to do better. Hence the benchmarking exercise.
>
> Perhaps make a closure that, when called, does the rendering to dc,
>> and treat the closure as a representation for the image?  Then let the
>> image and pict combiners operate on the closures to produce more
>> closures?
>
>
>
> Alex:
>
> I'm using rendering to a bitmap% in the case of the pict library as a
> proxy for direct rendering to a dc. I would certainly  render directly if I
> were to switch to pict.
>
> Timings vary on the actual layout in Quilt Explorer, depending on block
> complexity. The 18 blocks at the bottom of the page are choices in block
> layout / shading or color that the user can click on — that's the
> "exploring" part.
>
> A "next level" improvement might be something similar to the "virtual dom"
> pioneered (or at least popularised) by the react-js folk, to simplify and
> reduce the cost of re-rendering.
>
> Dan
>
>
>
>
> On Fri, Apr 28, 2017 at 11:05 PM, Alex Harsanyi 
> wrote:
>
>> On Friday, April 28, 2017 at 6:40:06 PM UTC+8, Daniel Prager wrote:
>>
>> > The reason is that what I really want to do is more complex layouts,
>> for which 2htdp/image or pict combiners make life a lot easier.
>>
>> The code to convert to bitmap allocates the bitmap and draws to the
>> bitmap.  In the actual application you can draw directly to the canvas DC
>> in the on-paint method, which would save a bitmap allocation and an
>> intermediate draw step.
>>
>> >
>> > Some work-in-progress ...
>> >
>> > The idea of Quilt Explorer is to use symmetry and randomness, combined
>> with some user selection to create original quilt designs.
>>
>> looking at these designs, I think by the time you're done writing code
>> that draws directly to a dc, the code will be just as slow as the pict
>> code, and probably with more bugs.
>>
>> Also, it seems you are rendering about 20 designs on the page.
>>
>> How long does it take to render an actual quilt design?
>>
>> Best Regards,
>> Alex.
>
> --
> 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] Speeding up graphics / moving away from 2htdp/image

2017-04-25 Thread WarGrey Gyoudmon Ju
Hi Daniel,

I have a functional bitmap library[1] as a part of my CSS engine.
This library is inspired by the official pict-lib and flomap(images-lib),
and handles bitmap% directly.
I don't think it is efficient enough since every functional operation
creates another bitmap%.

Here I recommend you to take a look at the flomap, it is written in typed
racket and represents high precision
bitmap objects with flvector, composition and transformation should
therefore efficient. You just need to convert
the flomap struct into a bitmap% instance when drawing(you might need to
take care of the backing scale).

The basic composition is simple, you can write your own version within a
day, but the performance ceiling may
relate to Racket instead of algorithms you picked(since algorithms are
already simple enough). If performance
is really a problem, you may want to write your own library with Racket
Futures.

[1]https://github.com/wargrey/css/tree/master/bitmap

On Wed, Apr 26, 2017 at 12:09 PM, Daniel Prager 
wrote:

> Much as I enjoy making images using 2htdp/image it does get a tad slow as
> complexity increases.
>
> I currently have a program in which I generate images in 2htdp/image and
> translate them into bitmap%s per racket/gui and render on canvas%'s via a
> dc.
>
> Speed has become sluggish and I'm going to need to move away from
> 2htdp/image to address this.
>
> A typical image is built up out of lots of above, beside, overlay, square,
> and triangle calls.
>
> Does anyone have a "clever" way to do this programatically (rather than a
> manual re-write with lots of absolute calculations replacing heights and
> widths)?
>
> Many thanks
>
> Dan
>
>
> --
> 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] [racket][draw] some APIs should be more open

2017-04-13 Thread WarGrey Gyoudmon Ju
Sorry I didn't describe my idea clearly before.

Actually, in my framework (I've been writing a CSS Engine), all those
objects are immutable and singular by design. The problem is, there is no
way for client application to tell those primary classes "The object is
already immutable".

(define rgba%
  (class inspectable-color%
(init [red  (random 255)]
   [green (random 255)]
   [blue (random 255)]
   [alpha 1.0])

(init-field [immutable? #true])

(super-make-object red green blue alpha)

(define/override (set red green blue [alpha 1.0])
  (when immutable? (error 'rgba% "color is immutable"))
  (super set red green blue alpha))

(define/override (copy-from src)
  (set (send this red) (send this green) (send this blue) (send this
alpha))
  this)

(define/override (is-immutable?)
  immutable?)

(define/override (inspect)
  (list (send this red) (send this green) (send this blue) (send this
alpha)


In this example, inspectable-color% is a subclass of color% and implements
`printable<%>` whose methods use the value of (inspect) to print its
instance. Here I have to add an extra field `immutable?` for overriding all
setter methods(This is what I meant "wordy code"), this is okay for client
application, but racket/draw still thinks the color is mutable since the
only way to make immutable color is calling (make-color) which use the
hidden public method (set-immutable).  Every time passing a custom color
object to Pen% and Brush%, it is copied.

For these simple object what I exactly asked for is to make (set-immutable)
method usable.

Font is the most complicated among them, even Pango cannot handle the
complexity well, this is a long term plan I will keep an eye on. For now,
since CSS Specification defines lots of font-relative units, and
racket/draw does not provide all the interface to obtain them(this is the
so-called "in-practical" situation mentioned by the spec). Just like
(get-handler)  exists widely in racket/draw and racket/gui, I wonder if it
is possible for font% to provide a same method, so that these duplicate
code are avoided:

(define make-desc+extent
(lambda [font-face font-size font-style font-weight]
  (define font-desc
(let ([face-is-family? (regexp-match #rx"," font-face)])
  (cond [(not face-is-family?) (pango_font_description_from_string
font-face)]
[else (let ([desc (pango_font_description_new)])
(pango_font_description_set_family desc font-face)
desc)])))
  (unless (eq? font-style 'normal) (pango_font_description_set_style
font-desc (~style font-style)))
  (unless (eq? font-weight 'normal) (pango_font_description_set_weight
font-desc (~weight font-weight)))
  (pango_font_description_set_absolute_size font-desc (* font-size
PANGO_SCALE))

  (define layout (or (unbox ) (and (set-box! 
(pango_cairo_create_layout cr)) (unbox 
  (pango_layout_set_font_description layout font-desc)

  (let ([baseline (pango_layout_get_baseline layout)])
(values font-desc baseline (λ [hint-char] (~extent layout baseline
hint-char))

  (define ~extent
(lambda [layout baseline hint-char]
  (pango_layout_set_text layout hint-char)
  (pango_layout_get_extents layout  )

  (define-values (x y width height) (~rectangle ))
  (define layout-height (PangoRectangle-height ))

  (values x y width height layout-height)))

or, just allow (get-text-extent) functions and methods returning the ink
metrics instead of the logical one.

I prefer the former.


On Wed, Apr 12, 2017 at 10:23 PM, George Neuner <gneun...@comcast.net>
wrote:

>
> On 4/11/2017 10:41 PM, WarGrey Gyoudmon Ju wrote:
>
>> This is a little awkward, there are lots of simple classes defined in
>> racket/draw, font%, color%, pen%, brush% and so on. They just hold a group
>> of plain data, hence opportunities to be inspected easily. However by
>> default all classes are opaque, the easiest (and perhaps unique) way to
>> handle this is to inherit them and implement the `printable<%>` or
>> `writable<%>`.
>>
>> Despite the wordy code and wasting little runtime space, the major
>> problem is all those classes hide their (set-immutable) methods, even
>> worse, the immutability is checked through the private field. As a
>> consequence, subclasses of Pen% and Brush% copy color instances every time
>> to make them immutable (and opaque) again...
>>
>> So is it okay to open that interface?
>>
>
> A lot of graphic APIs - Windows, X, Display Postscript, etc. - discourage
> modifying a resource while the resource is selected in a drawing context.
>  Of course, you aren't actively prevented from doing it ... but bad things
> - including serious crashes - ma

[racket-users] [racket][draw] some APIs should be more open

2017-04-11 Thread WarGrey Gyoudmon Ju
This is a little awkward, there are lots of simple classes defined in
racket/draw, font%, color%, pen%, brush% and so on. They just hold a group
of plain data, hence opportunities to be inspected easily. However by
default all classes are opaque, the easiest (and perhaps unique) way to
handle this is to inherit them and implement the `printable<%>` or
`writable<%>`.

Despite the wordy code and wasting little runtime space, the major problem
is all those classes hide their (set-immutable) methods, even worse, the
immutability is checked through the private field. As a consequence,
subclasses of Pen% and Brush% copy color instances every time to make them
immutable (and opaque) again...

So is it okay to open that interface?
Besides, With a long term plan, I want to improve the font infrastructure,
meanwhile maybe font% also should provide a (get-handler) or (get-desc).

-- 
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] Reporting exceptions as though they came from the caller

2017-03-31 Thread WarGrey Gyoudmon Ju
I use continuation marks to extract the nearest named function (named loops
are also contained in the context):

(define-syntax (#%function stx) ; class method has a symbol name looks like
"[name] method in [class%]"
  #'(let use-next-id : Symbol ([stacks (continuation-mark-set->context
(current-continuation-marks))])
  (if (null? stacks) 'λ
  (or (caar stacks)
  (use-next-id (cdr stacks))

with

(define-syntax (throw stx)
  (syntax-parse stx
[(_ st:id rest ...)
 #'(throw [st] rest ...)]
[(_ [st:id argl ...] frmt:str v ...)
 #'(throw [st argl ...] (#%function) frmt v ...)]
[(_ [st:id argl ...] src frmt:str v ...)
 #'(raise (st (format (string-append "~s: " frmt) src v ...)
(current-continuation-marks) argl ...))]))

this macro works much like `error`, and it allows you passing additional
arguments if the exception has more arguments:

(define (throw-exn) : Nothing
(throw [exn:fail:network:errno (cons 1 'posix)] "message: ~a" (gensym)))

On Sat, Apr 1, 2017 at 4:00 AM, David Storrs  wrote:

> Imagine I have the following trivial module (ignore that things are
> defined out of sequence for clarity):
>
> #lang racket
>
> (define (foo arg)
> (_baz arg)  ; do some checking, raise an exception if there's a problem
> ...do stuff...
> )
>
> (define (bar arg)
> (_baz arg)  ; do some checking, raise an exception if there's a problem
> ...do stuff)
>
> (define (_baz arg)  ; internal helper function
> (when (equal? arg "bad value")
> (raise-arguments-error '_baz "got a bad value" "val" val))) ;;
> <=== report is from _baz, not foo or bar
>
> (provide foo bar)
>
>
> In Perl I can use caller() [1] to access the stack so that I can have _baz
> report errors as though the error were coming from 'foo' or 'bar' as
> appropriate -- which is what the user expects to see, since their code
> called 'foo' or 'bar', not '_baz'.  (Even better, I could report as though
> the error were coming from the *caller* of foo / bar, which is the user's
> actual code and the real source of the problem.) How can I do the same in
> Racket?  I see the errortrace library, but that says "don't install this
> into a module and expect it to work."
>
> I could pass the name down, of course, but that's clumsy.  I could also
> create a parameter and set it every time I call the helper function that
> needs it, but that's even more clumsy / action-at-a-distance-y and easy to
> forget.  What's the right way?
>
>
> [1] https://perldoc.perl.org/functions/caller.html
>
> --
> 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] Typed Racket: Using (Sequenceof a) in place of (Listof a)

2017-03-21 Thread WarGrey Gyoudmon Ju
For input arguments, it's okay, (Sequenceof a) does accept (Listof a);
but for the return value, (Listof a) does not accept (Sequenceof a).

You can pass a list as the input, but you cannot narrow the type annotation
in you example,
say (list->vector) satisfies the annotation, both the input and output are
sequences, but the output is not a list.


Nonetheless, you can try the intersection type:

(: step (All (a b)
 (-> (-> a (∩ (Sequenceof a) b) (∩ (Sequenceof a) b))
 a
 (∩ (Sequenceof a) b)
 (∩ (Sequenceof a) b
(define (step fn x seq)
  (fn x seq))


On Tue, Mar 21, 2017 at 12:46 PM, Sourav Datta 
wrote:

> Hello all!
>
> I have a question regarding how sequence abstraction works in TR. In the
> sequence part of the docs it says that a sequence can consist of lists or
> vectors among other things. But does this make a function which ideally
> accepts a (Listof a) to accept something that is declared as a (Sequenceof
> a)? For example, in TR this works:
>
> (: x (Sequenceof Symbol))
> (define x '(a b c d))
>
> However, this shows a type mismatch:
>
> #lang typed/racket
>
> (: step (All (a)
>  (-> (-> a (Sequenceof a) (Sequenceof a))
>  a
>  (Sequenceof a)
>  (Sequenceof a
> (define (step fn x seq)
>   (fn x seq))
>
>
> (step (ann cons (-> Symbol (Listof Symbol) (Listof Symbol)))
>   'a
>   '(b c))
>
> Results in:
>
> Type Checker: Polymorphic function `step' could not be applied to
> arguments:
> Argument 1:
>   Expected: (-> a (Sequenceof a) (Sequenceof a))
>   Given:(-> Symbol (Listof Symbol) (Listof Symbol))
> Argument 2:
>   Expected: a
>   Given:'a
> Argument 3:
>   Expected: (Sequenceof a)
>   Given:(List 'b 'c)
>
> I think, trying to instantiate the polymorphic step function might help
> but I was not able to figure out how.
>
> Thanks in advance.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] link: bad variable linkage

2017-03-11 Thread WarGrey Gyoudmon Ju
I have this issue in Racket 6.8.0.1 this morning, the project is compiled
by compile-directory-zos, and all .zos are ensured up-to-date.
Before I gave up, I had wrote a simple tests in DrRacket, lucky to saw the
root cause, a contract error in the body of the newly added typed class,
but the issue was reported with two totally irrelevant modules.

On Sat, Feb 4, 2017 at 9:31 AM, Robby Findler 
wrote:

> This is the commit:
>
> https://github.com/racket/drracket/commit/81d74e484c306c3584030cf8ede298
> 25c0e8be1a
>
> I pushed it around the time 6.5 was released and it is the kind of
> thing I would do right after a release branch has been created, so
> probably it was only 6.6 and later.
>
> Robby
>
>
>
> On Fri, Feb 3, 2017 at 7:15 PM, Dan Liebgold
>  wrote:
> > On Saturday, March 26, 2016 at 4:53:51 PM UTC-7, Robby Findler wrote:
> >> Matthew and I have figured out one way in which DrRacket could go
> >> wrong here and implemented a better strategy. The problem we
> >> identified doesn't explain the symptoms expressed here in this thread
> >> exactly, but it is a complex system and maybe there was some piece
> >> missing from the explanations that I didn't think to ask about.
> >> Finger's crossed that it helps!
> >>
> >
> > I was getting this error and variations on it somewhat often in version
> 6.5. Do you think upgrading to 6.8 will help?
> >
> > Thanks,
> > Dan
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread WarGrey Gyoudmon Ju
Sorry for so many small mails on one topic.

In my current project, I implements something similar to line numbers.
At the beginning, I separate them into different canvases so that the GUI
behaves like iTunes(later I found that they do not implement it in a
consistent way), but now I like the way that racket already provides, to
override the (on-paint) method of text%, its first argument gives the
change to draw something before or after the text% itself is displayed.

On Thu, Mar 9, 2017 at 9:51 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com>
wrote:

> Okay, in the gui framework, there is an interface text:line-numbers<%>
>
> On Thu, Mar 9, 2017 at 9:46 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com
> > wrote:
>
>> But sometimes I happened to see that some one-line codes and their line
>> number are overlapped.
>> And line numbers are also controlled by the same horizontal scrollbar(I
>> mean, it is contained in the scrollbar's view, if there is another canvas
>> this should not happen).
>>
>> Maybe they are displayed in a special image box(also, those non-string
>> snips may produce lines that bigger than text line height).
>>
>> On Thu, Mar 9, 2017 at 9:31 AM, WarGrey Gyoudmon Ju <
>> juzhenli...@gmail.com> wrote:
>>
>>> I think, line numbers are likely displayed in another canvas.
>>> The current implementation of text% does not support advanced font
>>> features, the line height therefore is always the same. Displaying the line
>>> numbers just consists of a bit of arithmetic.
>>>
>>> On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇 <guluguluc...@gmail.com> wrote:
>>>
>>>>   I want to implement a text% object. And display the line number when
>>>> string is inserted the text/canvas area.
>>>>   Like the DrRacket IDE in "show line number" mode.
>>>>   I read the source code of DrRacket but do not find the answer. Could
>>>> anyone give a hand?
>>>>
>>>> --
>>>> 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] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread WarGrey Gyoudmon Ju
Okay, in the gui framework, there is an interface text:line-numbers<%>

On Thu, Mar 9, 2017 at 9:46 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com>
wrote:

> But sometimes I happened to see that some one-line codes and their line
> number are overlapped.
> And line numbers are also controlled by the same horizontal scrollbar(I
> mean, it is contained in the scrollbar's view, if there is another canvas
> this should not happen).
>
> Maybe they are displayed in a special image box(also, those non-string
> snips may produce lines that bigger than text line height).
>
> On Thu, Mar 9, 2017 at 9:31 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com
> > wrote:
>
>> I think, line numbers are likely displayed in another canvas.
>> The current implementation of text% does not support advanced font
>> features, the line height therefore is always the same. Displaying the line
>> numbers just consists of a bit of arithmetic.
>>
>> On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇 <guluguluc...@gmail.com> wrote:
>>
>>>   I want to implement a text% object. And display the line number when
>>> string is inserted the text/canvas area.
>>>   Like the DrRacket IDE in "show line number" mode.
>>>   I read the source code of DrRacket but do not find the answer. Could
>>> anyone give a hand?
>>>
>>> --
>>> 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] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread WarGrey Gyoudmon Ju
But sometimes I happened to see that some one-line codes and their line
number are overlapped.
And line numbers are also controlled by the same horizontal scrollbar(I
mean, it is contained in the scrollbar's view, if there is another canvas
this should not happen).

Maybe they are displayed in a special image box(also, those non-string
snips may produce lines that bigger than text line height).

On Thu, Mar 9, 2017 at 9:31 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com>
wrote:

> I think, line numbers are likely displayed in another canvas.
> The current implementation of text% does not support advanced font
> features, the line height therefore is always the same. Displaying the line
> numbers just consists of a bit of arithmetic.
>
> On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇 <guluguluc...@gmail.com> wrote:
>
>>   I want to implement a text% object. And display the line number when
>> string is inserted the text/canvas area.
>>   Like the DrRacket IDE in "show line number" mode.
>>   I read the source code of DrRacket but do not find the answer. Could
>> anyone give a hand?
>>
>> --
>> 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] racket/gui -- How to implement a text% area with line number displayed?

2017-03-08 Thread WarGrey Gyoudmon Ju
I think, line numbers are likely displayed in another canvas.
The current implementation of text% does not support advanced font
features, the line height therefore is always the same. Displaying the line
numbers just consists of a bit of arithmetic.

On Thu, Mar 9, 2017 at 8:31 AM, 武晓宇  wrote:

>   I want to implement a text% object. And display the line number when
> string is inserted the text/canvas area.
>   Like the DrRacket IDE in "show line number" mode.
>   I read the source code of DrRacket but do not find the answer. Could
> anyone give a hand?
>
> --
> 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] How to type annotate for bindings in complex syntax forms

2017-03-06 Thread WarGrey Gyoudmon Ju
1.5 years ago, I struggled with the command-line, finally I thought
`parse-command-line` is friendlier than its macro form `command-line`, and
got the solution with `cast`:

;;; firstly, define your precise Help-Table.
(define-type Help-Table
  (Listof (U (Pairof 'usage-help String)
  (Pairof 'once-each (Listof (List (Listof String)
  (U (->
String String Void)
   (->
String Void))
  (Listof
String)))

((cast parse-command-line (-> String (Vectorof String) Help-Table (-> Any
Void) (Listof String) (-> String Void) Void))
   (format "~a ~a" (#%module) (path-replace-suffix (cast
(file-name-from-path (#%file)) Path) #""))
   (current-command-line-arguments)
   `([usage-help . ,(format "~a~n" desc)]
 [once-each [("-p") ,(λ [[_ : String] [port : String]] (sakuyamon-port
(cast (string->number port) (Option Index
("Use an alternative ." "port")]
[("-w") ,(λ [[_ : String] [mw : String]]
(sakuyamon-max-waiting (cast (string->number mw) Positive-Index)))
("Maximum number of clients can be waiting for
acceptance." "mw")]
[("-t") ,(λ [[_ : String] [ict : String]]
(sakuyamon-connection-timeout (cast (string->number ict) Positive-Index)))
("Initial connection timeout." "ict")]
[("--SSL") ,(λ [[_ : String]] (sakuyamon-ssl? #true))
("Enable SSL with 443 as default port.")]])
   (λ [!] (serve-forever))
   null
   (lambda [[-h : String]]
 (display (string-replace -h #px"  -- : .+?-h --'\\s*" ""))
 (exit 0)))

at that time, I was a freshman to typed racket, hence so many `cast` in the
solution. The `cast` form is inefficient, but in that situation it's
ignorable.
The other reason was, the annotation of `parse-command-line` lacks the 6th
optional argument which I always need to filter the help message.

Yes, it's ugly, but better than losing the type information of important
parts.
Engineering is the art of tradeoffs.

On Mon, Mar 6, 2017 at 3:08 PM, kay  wrote:

> For a complex syntax form like `command-line`, I have difficulty correctly
> annotate the bindings it defines.
>
> More specifically, in the below code, for variable `msg`, even the
> document[1] says the `#:args` binds as list of **strings**, but the error
> indicates that it somehow is declared as `Listof Any`.
>
> Similarly, for variable `ch` bound in line 11, I believe it should always
> be `String`, but it somehow is declared to be `Any`.
>
> What should I do with this type of error, if I want my varaibles to be
> more precisely typed than just `Any`?
>
>
> [1]: https://docs.racket-lang.org/reference/Command-Line_
> Parsing.html?q=command-line#%28form._%28%28lib._racket%
> 2Fcmdline..rkt%29._command-line%29%29
>
> ```
>  1  #lang typed/racket
>  2
>  3  (define *channel* (make-parameter "#general"))
>  4  (define *message* : (Parameterof (Listof String)) (make-parameter
> '()))
>  5
>  6
>  7  (define (parse-cmdline)
>  8  (command-line
>  9   #:program "q"
> 10   #:once-each
> 11   [("-c" "--channel") ch "slack channel to post (default: use
> .qrc setting or default)" (*channel* ch)]
> 12   #:args msg
> 13   (*message* msg)))
> 14
> 15
> 16  #|
> 17  tr.rkt:11:91: Type Checker: Wrong argument to parameter - expected
> String and got Any in: (*channel* ch)
> 18  tr.rkt:13:5: Type Checker: Wrong argument to parameter - expected
> (Listof String) and got (Listof Any) in: (*message* msg)
> 19  |#
> ```
>
> --
> 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] Typed Racket: Polymorphic function `dynamic-wind' could not be applied to arguments

2017-03-05 Thread WarGrey Gyoudmon Ju
The problem is not the `AnyValues` since it accepts all types, but you
cannot instantiate a polymorphic type to return multiple values, so you
have to return (cons ... ...) in dynamic-wind then extract that pair as two
return values of the function.

On Sun, Mar 5, 2017 at 3:23 PM, kay  wrote:

> I have the following simple module that I'm converting to typed/racket. I
> got a type check error that I don't know how to fix. More specifically,
> it's related to the polymorphic function dynamic-wind's arguments. I read
> from document [1] that type inference doesn't work for a lambda that is an
> argument to a polymorphic function. But since here the three arguments are
> all thunks (without input argument), I don't know how to properly annotate
> them.
>
> Note that I tried to even annotate the first argument:
>
>   (λ () (ann #f AnyValues))
>
> And the type checker complained:
>
>   Argument 1:
> Expected: (-> AnyValues)
> Given:(-> AnyValues)
>
> which is really weird.
>
>
> [1]: https://docs.racket-lang.org/ts-guide/more.html#%28part._
> when-annotations~3f%29
>
>
>
> Here's the module:
> --
>
> #lang typed/racket
>
> ;;(require racket/string racket/list racket/match racket/system
> racket/port racket/function)
> (provide execute)
>
> (: execute (-> String * (Values String String)))
> (define (execute . args)
>   (define cmdln (string-join args))
>   (displayln (format "running ~a" cmdln))
>   (match (process cmdln)
> [(list out in pid err f)
>
>  (define cust (make-custodian))
>  (dynamic-wind
>   (λ () (ann #f AnyValues))
>
>   (thunk
>(parameterize ([current-custodian cust])
>  (define buf_stdout (open-output-string))
>  (define buf_stderr (open-output-string))
>
>  (thread (λ () (copy-port out buf_stdout (current-output-port
>  (thread (λ () (copy-port err buf_stderr (current-error-port
>
>  (displayln (f 'status))
>  (f 'wait)
>
>  (values (get-output-string buf_stdout) (get-output-string
> buf_stderr
>
>   (thunk (custodian-shutdown-all cust)))
>  ]))
>
>
>
>
> Here's the type error:
> --
>
> . executor.rkt:14:5: Type Checker: Polymorphic function `dynamic-wind'
> could not be applied to arguments:
> Argument 1:
>   Expected: (-> AnyValues)
>   Given:(-> AnyValues)
> Argument 2:
>   Expected: (-> a)
>   Given:(-> (values (String : (Top | Bot)) (String : (Top | Bot
> Argument 3:
>   Expected: (-> AnyValues)
>   Given:(-> Void)
>
> Result type: a
> Expected result: (values String String)
>  in: (dynamic-wind (λ () (ann #f AnyValues)) (thunk (parameterize
> ((current-custodian cust)) (define buf_stdout (open-output-string)) (define
> buf_stderr (open-output-string)) (thread (λ () (copy-port out buf_stdout
> (current-output-port (thread (λ () (copy-port err buf_stderr
> (current-error-port (displayln (f (quote status))) (f (quote wait))
> (values (get-output-string buf_stdout) (get-output-string buf_stderr
> (thunk (custodian-shutdown-all cust)))
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] [racket][gui] maybe different behaviors of text% between Windows and macOS

2017-02-12 Thread WarGrey Gyoudmon Ju
Hello, the original problem is reported here[
https://github.com/racket/racket/issues/1573]
My solution works well in macOS, but in Windows, it only "partially" works:

If there is no newline (including the one produced by *auto-wrap*) in the
texts, it works, or only the last line is rendered well, all head lines are
not combined.

So, are there any magic things relates to windows or newlines?
Thanks.

-- 
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 implement a dynamic plugin system?

2017-02-07 Thread WarGrey Gyoudmon Ju
I think you can check the source of `raco` which uses the `info.rkt` to
search all subcommands(see `racket/getinfo`). In this way, all plugins are
just normal packages, you do not have to reside them is a specific
directory. Certainly, the plugin is loaded via `dynamic-require`, if the
plugin needs the imports of main application, I think sandbox is not
necessary.

More precision, a plugin is just a normal module, if it requires the
modules that your main application uses, they will share the same status,
say you can use `(parameterize
([common-or-specific-parameters-for-the-plugin val]) (dynamic-require "..."
'greetings))` to let the plugin know its working environment; Inside the
plugin, it provides a name `greetings` with a structured value that
contains the proper icons, panel instances and so on, then the main
application will know how to deal with the plugin.

In my application, I prefer the logging facility, unlike logging facilities
in other languages, the racket one is also a multi dispatching asynchronous
mechanism which is more efficient than pipes and channels (if you do not
use place). The typical use case is, the splash screen and the main
application are both listening on the `current-logger`, and the plugin logs
itself with the proper info to `current-logger`, then the splash screen
will know a new icon should be drawn, while the main application will know
a new panel should be added to the workspace (both of them will receive all
the info but only pick up the interesting parts).

On Tue, Feb 7, 2017 at 7:21 PM, Erich Rast  wrote:

> Hi all!
>
> I'm thinking about implementing a dynamic plugin system for a large
> application. Each plugin should have the full racket/gui language and a
> number of pre-defined imports from modules of the main application
> available. Plugins should reside in a relative directory and loadable
> on demand at runtime, and I also need a way to check in the main
> application that they export certain plugin data like a name, an icon
> and a panel% class. Plugins do not need to export any macros. Security
> is not a concern and all plugins are local.
>
> My questions: Is that possible? What's the right way of doing it, should
> I use dynamic-require or racket/sandbox? How would you convert an
> ordinary module with a #lang statement and various requires into such a
> dynamic plugin?
>
> Best,
>
> Erich
>
> --
> 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] Package layout in docs

2017-01-31 Thread WarGrey Gyoudmon Ju
On Tue, Jan 31, 2017 at 9:12 PM, Matthias Felleisen <matth...@ccs.neu.edu>
wrote:

>
> > On Jan 31, 2017, at 12:37 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com>
> wrote:
> >
> > Hello.
> >
> > This is one of the culture shocks that a new Racketeer would face, and
> so was I.
> > But this statement makes it clear to me: Racket is an operating system
> that pretend to a programming language;
> >
> > Yes, it may totally be a kind of over reading here.
>
>
> No, you’re not. See third principle of the Racket Manifesto
> (internalization) and the Revenge of the Son of the Lisp Machine.


Oh, I just forgot the Manifesto[1].
So why not give it an entry in the index page? just like "How to Program
Racket: a Style Guard";
or make a margin-note that links to it in the section "Naming and Designing
Packages"[2].

[1] http://www.ccs.neu.edu/home/matthias/manifesto/
[2]
https://docs.racket-lang.org/pkg/getting-started.html#%28part._.Naming_and_.Designing_.Packages%29

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

2017-01-30 Thread WarGrey Gyoudmon Ju
Hello.

This is one of the culture shocks that a new Racketeer would face, and so
was I.
But this statement makes it clear to me: Racket is an operating system that
pretend to a programming language;

Yes, it may totally be a kind of over reading here.

Say, I do not care if a manual page is the one shipped with unix
distribution or installed by user, same to shell commands and shared
objects, all entries should globally unique.

Okay, the documentation system is a little different here, it can be
provided with a different front page, and obviously there is no way to
satisfy all.
Actually I am afraid of where to insert the entry of my package as well.

Of my preference, I would suggest putting status icons (or even emojis) in
front of every entry in the index page based on the ring system.


On Tue, Jan 31, 2017 at 11:57 AM, Philip McGrath 
wrote:

> I was also going to suggest the ring system as a way of giving more
> information without imposing an unnecessary artificial distinction. In
> general I'm enthusiastic about the benefits of not having a sharp dividing
> line, but it would be useful to show more clearly in the documentation
> which packages have been vetted to "ring zero" standards.
>
>
>
>
> On Mon, Jan 30, 2017 at 8:46 PM, Jack Firth  wrote:
>
>> Rather than splitting "core packages" from "community packages", what if
>> we used the package ring system? [1] We could establish a way for the
>> Racket community to bless packages with "ring zero" status, then provide a
>> --catalog argument to Scribble to lookup ring information in when deciding
>> how to style package documentation. The docs would remain unified, we'd
>> have a centralized place to curate packages, and there's no artificial
>> barrier that prevents user-contributed packages from living alongside
>> main-distribution packages.
>>
>> [1] http://docs.racket-lang.org/pkg/Future_Plans.html?q=ring
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] specify test timeout for pkg-build?

2017-01-28 Thread WarGrey Gyoudmon Ju
Thank you Robby.
Good to know this.

On Sat, Jan 28, 2017 at 9:25 PM, Robby Findler <ro...@eecs.northwestern.edu>
wrote:

> The pkg-build running here would pick up those changes, tho, so you
> could see the results:
>
>   https://plt.eecs.northwestern.edu/pkg-build/
>
> It runs based on the latest snapshot (from
> https://plt.eecs.northwestern.edu/snapshots/)  instead of the release.
>
> Robby
>
> On Fri, Jan 27, 2017 at 10:52 PM, Matthew Flatt <mfl...@cs.utah.edu>
> wrote:
> > That sounds like a reasonable addition to `raco test`, and I'll look
> > into adding it soon. (The addition won't be effective in
> > pkg-build.racket-lang.org until the next release, though.)
> >
> > At Sat, 28 Jan 2017 11:23:44 +0800, WarGrey Gyoudmon Ju wrote:
> >> And also, I want to control `--check-stderr` in `info.rkt` file.
> >>
> >> 1. currently, typed racket complains any `ctype?` types and warns it to
> >> stderr.
> >> 2. for some tests, display their output to stdout and stderr is more
> >> convenient than wrapping the output into something like (check-exn?),
> say,
> >> to see if the error message is informative or well formatted.
> >>
> >> then pkg-build thinks the package has test failures.
> >>
> >> On Sat, Jan 28, 2017 at 4:37 AM, Stephen Chang <stch...@ccs.neu.edu>
> wrote:
> >>
> >> > I have a package whose tests are timing out when run by pkg-build. Is
> >> > there a way to extend this timeout?
> >> >
> >> > I know I can specify individual file timeouts with `test-timeouts` but
> >> > I couldnt figure out how to specify a timeout for testing the whole
> >> > package. Is this possible?
> >> >
> >> > Steve
> >> >
> >> > --
> >> > You received this message because you are subscribed to the Google
> Groups
> >> > "Racket Users" group.
> >> > To unsubscribe from this group and stop receiving emails from it,
> send an
> >> > email to racket-users+unsubscr...@googlegroups.com.
> >> > For more options, visit https://groups.google.com/d/optout.
> >> >
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>

-- 
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] specify test timeout for pkg-build?

2017-01-28 Thread WarGrey Gyoudmon Ju
Thank you Matthew.

And, Racket will still be faster than my unstable packages.

On Sat, Jan 28, 2017 at 12:52 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> That sounds like a reasonable addition to `raco test`, and I'll look
> into adding it soon. (The addition won't be effective in
> pkg-build.racket-lang.org until the next release, though.)
>
> At Sat, 28 Jan 2017 11:23:44 +0800, WarGrey Gyoudmon Ju wrote:
> > And also, I want to control `--check-stderr` in `info.rkt` file.
> >
> > 1. currently, typed racket complains any `ctype?` types and warns it to
> > stderr.
> > 2. for some tests, display their output to stdout and stderr is more
> > convenient than wrapping the output into something like (check-exn?),
> say,
> > to see if the error message is informative or well formatted.
> >
> > then pkg-build thinks the package has test failures.
> >
> > On Sat, Jan 28, 2017 at 4:37 AM, Stephen Chang <stch...@ccs.neu.edu>
> wrote:
> >
> > > I have a package whose tests are timing out when run by pkg-build. Is
> > > there a way to extend this timeout?
> > >
> > > I know I can specify individual file timeouts with `test-timeouts` but
> > > I couldnt figure out how to specify a timeout for testing the whole
> > > package. Is this possible?
> > >
> > > Steve
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups
> > > "Racket Users" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an
> > > email to racket-users+unsubscr...@googlegroups.com.
> > > For more options, visit https://groups.google.com/d/optout.
> > >
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] specify test timeout for pkg-build?

2017-01-27 Thread WarGrey Gyoudmon Ju
And also, I want to control `--check-stderr` in `info.rkt` file.

1. currently, typed racket complains any `ctype?` types and warns it to
stderr.
2. for some tests, display their output to stdout and stderr is more
convenient than wrapping the output into something like (check-exn?), say,
to see if the error message is informative or well formatted.

then pkg-build thinks the package has test failures.

On Sat, Jan 28, 2017 at 4:37 AM, Stephen Chang  wrote:

> I have a package whose tests are timing out when run by pkg-build. Is
> there a way to extend this timeout?
>
> I know I can specify individual file timeouts with `test-timeouts` but
> I couldnt figure out how to specify a timeout for testing the whole
> package. Is this possible?
>
> Steve
>
> --
> 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] Editor-canvas% how to set default style and use set-line-count correctly?

2017-01-26 Thread WarGrey Gyoudmon Ju
On Fri, Jan 27, 2017 at 1:46 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com>
wrote:
>
> (send card insert (make-object string-snip% "it's a bug of text%,
> snip's style is not (convert)ed, also affects the following inputs")
>

All right, it is not a bug, it's just how it works. the snip's style will
be convert into the-style-list and affects the following inputs.

Sorry for making so much nonsense words.

-- 
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] Editor-canvas% how to set default style and use set-line-count correctly?

2017-01-26 Thread WarGrey Gyoudmon Ju
Update: this solution does work.

I just found the reason why it did not work before.

(define digivice (new frame% [width 800] [height 600] [label "Standard
Style"]))
(define card (make-object text%))
(define darc (new editor-canvas% [parent digivice] [editor card] [style
'(no-border auto-hscroll auto-vscroll)]))
(define font (make-font #:face "Microsoft Himalaya" #:size 16))
(define color (make-object color% "ForestGreen"))

(change-default-style! card #:font font #:color color) ;;; this can be put
in the class body, or do it in editor-canvas%, it's up to you.

(send card insert "works as expected")
(send card insert (make-object string-snip% "it's a bug of text%,
snip's style is not (convert)ed, also affects the following inputs")
(send digivice show #true)
(send digivice center 'both)


On Fri, Jan 27, 2017 at 12:48 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com
> wrote:

> I have these two helpers (typed racket makes it a little verbose).
>
> (define change-style : (->* ((Instance Style<%>))
> (#:font (Option (Instance Font%))
>  #:color (Option (Instance Color%))
>  #:background-color (Option (Instance Color%)))
> (Instance Style<%>))
>   (lambda [style #:font [font #false] #:color [color #false]
> #:background-color [bgcolor #false]]
> (send style set-delta
>   (let* ([style (make-object style-delta%)]
>  [style (if (false? color) style (send style
> set-delta-foreground color))]
>  [style (if (false? bgcolor) style (send style
> set-delta-background bgcolor))])
> (cond [(false? font) style]
>   [else (send* style
>   (set-face (send font get-face))
>   (set-family (send font get-family)))
> (send+ style
>(set-delta 'change-style (send font
> get-style))
>(set-delta 'change-weight (send font
> get-weight))
>(set-delta 'change-smoothing (send font
> get-smoothing))
>(set-delta 'change-underline (send font
> get-underlined))
>(set-delta 'change-size (min (exact-round
> (send font get-size)) 255)))])))
> style))
>
> (define change-default-style! : (->* ((U (Instance Editor<%>) (Instance
> Style-List%)))
>   (#:font (Option (Instance Font%))
>#:color (Option (Instance Color%))
>#:background-color (Option
> (Instance Color%)))
>   (Instance Style<%>))
>   (lambda [src #:font [font #false] #:color [color #false]
> #:background-color [bgcolor #false]]
> (define-values (style-list style-name)
>   (cond [(text%? src) (values (send src get-style-list) (send src
> default-style-name))]
> [(pasteboard%? src) (values (send src get-style-list) (send
> src default-style-name))]
> [else (values (if (style-list%? src) src (make-object
> style-list%)) "Standard")]))
> (change-style #:font font #:color color #:background-color bgcolor
>   (or (send style-list find-named-style style-name)
>   (send style-list new-named-style style-name (send
> style-list basic-style))
>
> 
> 
> ;;
>
> This line is put in the class body of new instance of Editor<%> (not
> editor-canvas%):
>
> (change-default-style! this #:font font ...)
>
> The idea is attaching a style-delta% object to the standard style, then
> the altered style becomes
> the top-level one so that it will never be `undo`ed by accident.
>
> The awkward thing here is, I cannot make it work in a simple example,
> however it works fine in my real world application.
>
>
> On Thu, Jan 26, 2017 at 7:00 PM, Erich Rast <er...@snafu.de> wrote:
>
>> Hi,
>>
>> I have an editor-canvas% subclass and want to set the default style,
>> but adding it with name "Standard" to the-style-list doesn't work. Do
>> I have to replace the style list of the canvas with a new one? Or does
>> the default style of an editor-canvas% have to be called differently?
>> "Basic"?
>>
>> Without the right default style set-line-count also doesn't work as
>> desired. It sets the wrong size for lines with smaller font

Re: [racket-users] Editor-canvas% how to set default style and use set-line-count correctly?

2017-01-26 Thread WarGrey Gyoudmon Ju
I have these two helpers (typed racket makes it a little verbose).

(define change-style : (->* ((Instance Style<%>))
(#:font (Option (Instance Font%))
 #:color (Option (Instance Color%))
 #:background-color (Option (Instance Color%)))
(Instance Style<%>))
  (lambda [style #:font [font #false] #:color [color #false]
#:background-color [bgcolor #false]]
(send style set-delta
  (let* ([style (make-object style-delta%)]
 [style (if (false? color) style (send style
set-delta-foreground color))]
 [style (if (false? bgcolor) style (send style
set-delta-background bgcolor))])
(cond [(false? font) style]
  [else (send* style
  (set-face (send font get-face))
  (set-family (send font get-family)))
(send+ style
   (set-delta 'change-style (send font
get-style))
   (set-delta 'change-weight (send font
get-weight))
   (set-delta 'change-smoothing (send font
get-smoothing))
   (set-delta 'change-underline (send font
get-underlined))
   (set-delta 'change-size (min (exact-round
(send font get-size)) 255)))])))
style))

(define change-default-style! : (->* ((U (Instance Editor<%>) (Instance
Style-List%)))
  (#:font (Option (Instance Font%))
   #:color (Option (Instance Color%))
   #:background-color (Option (Instance
Color%)))
  (Instance Style<%>))
  (lambda [src #:font [font #false] #:color [color #false]
#:background-color [bgcolor #false]]
(define-values (style-list style-name)
  (cond [(text%? src) (values (send src get-style-list) (send src
default-style-name))]
[(pasteboard%? src) (values (send src get-style-list) (send src
default-style-name))]
[else (values (if (style-list%? src) src (make-object
style-list%)) "Standard")]))
(change-style #:font font #:color color #:background-color bgcolor
  (or (send style-list find-named-style style-name)
  (send style-list new-named-style style-name (send
style-list basic-style))

;;

This line is put in the class body of new instance of Editor<%> (not
editor-canvas%):

(change-default-style! this #:font font ...)

The idea is attaching a style-delta% object to the standard style, then the
altered style becomes
the top-level one so that it will never be `undo`ed by accident.

The awkward thing here is, I cannot make it work in a simple example,
however it works fine in my real world application.


On Thu, Jan 26, 2017 at 7:00 PM, Erich Rast  wrote:

> Hi,
>
> I have an editor-canvas% subclass and want to set the default style,
> but adding it with name "Standard" to the-style-list doesn't work. Do
> I have to replace the style list of the canvas with a new one? Or does
> the default style of an editor-canvas% have to be called differently?
> "Basic"?
>
> Without the right default style set-line-count also doesn't work as
> desired. It sets the wrong size for lines with smaller fonts that are
> added, so I assume this method is based on the default style. But which
> style is exactly the default style "Basic" or "Standard", and how do I
> change it?
>
> best,
>
> Erich
>
> -
>
> ; Example (sorry, not runnable, because it uses my own preference and
> ; what I call 'metastyle' impementation)
> ; layout-init does not really change the style, which
> ; is why I use set-style for every snip. But then set-line-count
> ; doesn't work as desired.
>
> (define console%
>   (class editor-canvas%
> (inherit scroll-with-bottom-base allow-scroll-to-last)
>
> (define text #f)
> (define console-style #f)
> (define sema (make-semaphore 1))
>
> (define (layout-init)
>   (define style (send the-style-list
>   find-named-style "Basic"))
>   (set! console-style (send the-style-list
> find-or-create-style
> style
> (metastyle->style
> (pref:console-style
>   (send the-style-list new-named-style "Standard" console-style)
>   (set! text
> (new text%
>  [auto-wrap #t]
>  [line-spacing 0]))
>   (send this set-editor text)
>   (scroll-with-bottom-base #t)
>   (allow-scroll-to-last #t)
>   (send this set-line-count 2))
>
> (define (synced-add-line msg)
>   (send text begin-edit-sequence)
>  

Re: [racket-users] Best practice for using .../private files from packages (pict3d)

2017-01-26 Thread WarGrey Gyoudmon Ju
How about merging these primitive geometry APIs into math-lib?


On Thu, Jan 26, 2017 at 8:53 PM, Jay McCarthy 
wrote:

> I think that it is quite common for a big library (especially
> something really big like pict3d) to create a lot of residual useful
> code that could conceivably be their own libraries. I suggest either
> [2] or [3] or even a new package for some sort of more primitive
> notion of geometry.
>
> Jay
>
> On Thu, Jan 26, 2017 at 7:48 AM, Tim Brown  wrote:
> > Folks,
> >
> > I want to access files from a “private” directory of a package -- in this
> > case pict3d -- but I was wondering what the best way to do this is.
> >
> > First a bit of context:
> >
> >   I am using the pict3d library for a project which allows me to render
> and
> >   experiment on various 3D models.
> >
> >   As an aside to that project, I have a small utility that only uses
> >   pict3d’s ‘pos’ and ‘dir’ types (and their algebra libraries)
> >
> >   I am happy for my “lab” to be massive (I need/want to fly through the
> models);
> >   but the utility will be used as part of a build process inside a
> low-memory
> >   docker instance† -- and needs to be quick.
> >
> >   I can `(require pict3d/private/gui/user-types)`; which avoids me
> needing to
> >   link in all the rest of GUI. And that is necessary and sufficient for
> my needs.
> >
> > My issue is with the “private” portion of that module path. It suggests
> > that its content and structure is at the convenience of the package’s
> > owner. From a “public” point of view, external to the package, I wouldn’t
> > expect ‘pos’ and ‘dir’ to disappear. And they are also well documented so
> > they form part of the API. But there is nothing to stop, for example,
> this
> > file from being refactored -- with the change being reconciled within the
> > overall package.
> >
> > So, I see I have a few options:
> >
> >   [1] (require pict3d/private/gui/user-types)
> >   and moan at the package owner if he breaks this for me
> >
> >   [2] Suggest and submit a change which moves
> >   .../pict3d/private/gui/user-types to .../pict3d/gui/user-types --
> >   and clean up the fallout from this, including triggering complaints
> >   a la [1]
> >
> >   [3] Suggest and submit a change which re-exports
> >   .../pict3d/private/gui/user-types from a new
> .../pict3d/gui/user-types
> >   (in fact, I’m not sure there’s anything necessarily “gui” about
> this
> >   part of the code) which to me looks to be the most correct option,
> but:
> > a. is this necessary
> > b. does this put me / the package onto a slippery slope of making
> >everything public
> >
> > Has anyone had any similar experience of using private package files that
> > they could share? Or any other thoughts on the matter.
> >
> > Tim
> >
> > † It took something like 30 minutes to `raco pkg install pict3d` on this
> >   thing, so `raco make _utility_` is probably a non-starter.
> >
> > --
> > Tim Brown CEng MBCS 
> > 
> > City Computing Limited · www.cityc.co.uk
> >   City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB
> > T:+44 20 8770 2110 · F:+44 20 8770 2130
> > 
> > City Computing Limited registered in London No:1767817.
> > Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
> > VAT No: GB 918 4680 96
> >
> > --
> > 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.


Re: [racket-users] How to embed version and build date in an application executable?

2017-01-05 Thread WarGrey Gyoudmon Ju
I realized I was wrong just after posting that email.
Then I figured the way using environment variables, but hesitated because I
never made the `create-embedding-executable` work if more arguments are
passed to it.

Vincent's way delights me.

On Fri, Jan 6, 2017 at 10:42 AM, Alex Harsanyi <alexharsa...@gmail.com>
wrote:

> Perhaps I should have clarified this better, but
>
> My application is an executable built with "create-embedding-executable",
> not a package, I'm not sure that the info.rkt can be compiled and packaged
> inside an exe.
>
> I would like to have this information compiled as a .zo file and embedded
> into this executable, so it cannot easily changed. My current solution is
> writing a separate file which is read at run-time, similar to what you
> proposed, but this has the downside that one can change the version just by
> editing the file.
>
> For reference, the application is https://github.com/alex-hhh/ActivityLog2,
> you can have a look at build.rkt for how it is currently done (it creates
> the file build-id.txt).
>
> Cheers,
> Alex.
>
> On Friday, January 6, 2017 at 10:31:43 AM UTC+8, WarGrey Gyoudmon Ju wrote:
> > A racket application usually has an `info.rkt` file in the root
> directory of the project/package/collection.
> > see https://docs.racket-lang.org/raco/getinfo.html
> >
> >
> > You can put your meta information in that file than read it with
> (get-info/full dirpath) which returns a function that works like `hash-ref`.
> >
> >
> > I recommend that way, there are also other alternatives.
> > One that match your example is, just (write)ing a racket list into
> "app-version.rktl" (note, "rktl" is also a conventional name, the "l"
> stands for "load"),
> > then you can (read) back it:
> >
> >
> >
> > (match-define (list app-version app-commit-id app-build-date)
> >   (with-handlers ([exn:fail:filesystem? (lambda [e] (list "dev build"
> "unknown" "no build"))])
> > (call-with-input-file "app-version.rkt" read)))
> >
> >
> > This alternative is simpler than the one using `info.rkt` when you
> update the meta information programmatically.
> >
>
> --
> 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] How to embed version and build date in an application executable?

2017-01-05 Thread WarGrey Gyoudmon Ju
A racket application usually has an `info.rkt` file in the root directory
of the project/package/collection.
see https://docs.racket-lang.org/raco/getinfo.html

You can put your meta information in that file than read it with
(get-info/full dirpath) which returns a function that works like `hash-ref`.

I recommend that way, there are also other alternatives.
One that match your example is, just (write)ing a racket list into
"app-version.rktl" (note, "rktl" is also a conventional name, the "l"
stands for "load"),
then you can (read) back it:

(match-define (list app-version app-commit-id app-build-date)
  (with-handlers ([exn:fail:filesystem? (lambda [e] (list "dev build"
"unknown" "no build"))])
(call-with-input-file "app-version.rkt" read)))

This alternative is simpler than the one using `info.rkt` when you update
the meta information programmatically.


On Fri, Jan 6, 2017 at 10:08 AM, Alex Harsanyi 
wrote:

> I would like to embed versioning and build date information in my
> application
> executable, and I'm not sure how to do that.  To clarify, in C or C++, I
> would
> write the following:
>
>#include 
>
>#ifndef APPVER
>#define APPVER "no version"
>#endif
>
>void main()
>{
> printf("%s\n", APPVER);
>}
>
> I can than compile the code by passing "-D APPVER=1.0" to the compiler
> command
> line and have it print the correct version.
>
> How can this be done in Racket?
>
> I don't really want to check-in a file with the version number in it, and
> besides, I would like to add my GIT commit ID and build date as well in the
> same way.
>
> My idea is that the build script would write a file like this at build
> time:
>
>#lang racket/base
>(define (app-version) "1.0")
>(define (app-commit-id) "abcdefg")
>(define (app-build-date) "06-01-2017T09:10:12")
>(provide app-version app-commit-id app-build-date)
>
> I would than require this file from other places, but only if it exists,
> something like this:
>
>(if (file-exists? "app-version.rkt")
>(require "app-version.rkt")
>(begin
>  (define (app-version) "dev build")
>  (define (app-commit-id) "unknown")
>  (define (app-build-date) "no build")))
>
> Unfortunately, the code above does not work because require needs to be
> defined at top level.
>
> Does anyone have any suggestions?
>
> Thanks,
> Alex.
>
> --
> 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] `apply`ing polymorphic functions in typed/racket

2017-01-05 Thread WarGrey Gyoudmon Ju
On Thu, Jan 5, 2017 at 3:28 PM, Matthew Eric Bassett 
wrote:
>
> the type signatures of this functions are:
> (-> (Setof e) (Setof e) * (Setof e))
>
> > (define list0
> (list (set 2) (set 3 2)))
>   (apply set-union list0)
>
> > (define list2 : (Listof (Setof Positive-Byte))
> (list (set 2) (set 3 2)))
>   (apply set-union list2)
>
> Why does the former work and the latter fail ?
>

because,
`list0` has a type `(List (Setof Positive-Byte) (Setof Positive-Byte))`
which is guaranteed to hold at least one set value.
`list2` may be `null`.

So you get it. `set-union` requires at least one set value as input.

-- 
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: hello, where can I find the distribution 6.7.0.3.

2017-01-04 Thread WarGrey Gyoudmon Ju
Hello, is this normal?
I found my released package still does not work.
This is the bug I mentioned above that shown in 6.7(and also in 6.6).

http://pkg-build.racket-lang.org/server/built/fail/digimon.txt

If the distribution is built from source, that bug does not exist.

I am sure it used to be okay 2 weeks ago.
Then I made a pull request for typed/setup/getinfo, and it was merged
within one day.
But the pkg-build.racket-lang.org does not update, so I made my source self
contained again,
Then it fails...


On Wed, Jan 4, 2017 at 11:39 PM, Andrew Kent <pnw...@gmail.com> wrote:

> At a glance, I believe the bug you're noticing on the snapshot is one we
> also recently observed -- it is fixed in a PR that should be pushed in the
> next couple of days (https://github.com/racket/typed-racket/pull/481).
>
> Sorry for the trouble.
>
> Best,
> Andrew
>
> On Wednesday, January 4, 2017 at 3:51:15 AM UTC-5, WarGrey Gyoudmon Ju
> wrote:
> > I cannot deploy my typed desktop application on Windows.
> >
> >
> > In the download home page, 6.7 does not work, and that bug seemed to be
> solved (I started 6.7 from 6.7.0.3, do not know whether it was okay on
> macOS).
> >
> >
> > The latest snapshot has a new bug shown both on macOS and Windows:
> >
> >
> >
> > in-list: contract violation
> >   expected: list?
> >   given: (hash (Object) #t b #t)
> >   compilation context...:
> > context...:
> >C:\Program Files\Racket-6.7.0.4\collects\racket\private\for.rkt:633:2:
> in-list
> >f184
> >C:\Program 
> > Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\type-rep.rkt:656:4:
> for-loop
> >C:\Program 
> > Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\type-rep.rkt:653:0:
> Union-map
> >f152
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\rep\rep-utils.rkt:191:8: Rep-fmap
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-subst.rkt:98:0: subst-tc-result
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-subst.rkt:35:0: values->tc-results5
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-funapp.rkt:45:0: tc/funapp
> >temp101
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-expr-unit.rkt:329:0: core914
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-if.rkt:13:0: core16
> >temp101
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-expr-unit.rkt:326:0: tc-expr
> >temp101
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-expr-unit.rkt:79:0: tc-expr/check
> >...
> >
> >
> > Would you please take me to the download page of 6.7.0.3? or one commit
> before this bug? (I don't want to build it from source because real users
> of this application have no knowledge on programming. Also I am working
> remotely, we should have an agile feedback and update process). Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: hello, where can I find the distribution 6.7.0.3.

2017-01-04 Thread WarGrey Gyoudmon Ju
Oh, thank you Andrew, you are making a great improvements.
Couple of days are not too long to wait.

On Wed, Jan 4, 2017 at 11:39 PM, Andrew Kent <pnw...@gmail.com> wrote:

> At a glance, I believe the bug you're noticing on the snapshot is one we
> also recently observed -- it is fixed in a PR that should be pushed in the
> next couple of days (https://github.com/racket/typed-racket/pull/481).
>
> Sorry for the trouble.
>
> Best,
> Andrew
>
> On Wednesday, January 4, 2017 at 3:51:15 AM UTC-5, WarGrey Gyoudmon Ju
> wrote:
> > I cannot deploy my typed desktop application on Windows.
> >
> >
> > In the download home page, 6.7 does not work, and that bug seemed to be
> solved (I started 6.7 from 6.7.0.3, do not know whether it was okay on
> macOS).
> >
> >
> > The latest snapshot has a new bug shown both on macOS and Windows:
> >
> >
> >
> > in-list: contract violation
> >   expected: list?
> >   given: (hash (Object) #t b #t)
> >   compilation context...:
> > context...:
> >C:\Program Files\Racket-6.7.0.4\collects\racket\private\for.rkt:633:2:
> in-list
> >f184
> >C:\Program 
> > Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\type-rep.rkt:656:4:
> for-loop
> >C:\Program 
> > Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\type-rep.rkt:653:0:
> Union-map
> >f152
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\rep\rep-utils.rkt:191:8: Rep-fmap
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-subst.rkt:98:0: subst-tc-result
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-subst.rkt:35:0: values->tc-results5
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-funapp.rkt:45:0: tc/funapp
> >temp101
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-expr-unit.rkt:329:0: core914
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-if.rkt:13:0: core16
> >temp101
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-expr-unit.rkt:326:0: tc-expr
> >temp101
> >C:\Program Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-
> racket\typecheck\tc-expr-unit.rkt:79:0: tc-expr/check
> >...
> >
> >
> > Would you please take me to the download page of 6.7.0.3? or one commit
> before this bug? (I don't want to build it from source because real users
> of this application have no knowledge on programming. Also I am working
> remotely, we should have an agile feedback and update process). Thank you.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] hello, where can I find the distribution 6.7.0.3.

2017-01-04 Thread WarGrey Gyoudmon Ju
Hi, Stephen, I've already tried 12.28 and no luck. And at this time, that
link is dead. So, all snapshots are temporary testers.

hi Dupéron, For me on my computer I always build it from source, but I
never trace the date and commit.
Actually this is one of the major reason I gave up Haskell, Racket can be
built in OpenIndiana without painful.
And, the same, I do not use Windows at all.

On Wed, Jan 4, 2017 at 6:09 PM, Dupéron Georges  wrote:

> I don't think the old "minor" versions are kept, only the last few as
> Stephen pointed out.
>
> As can be checked in the git log for https://github.com/racket/
> racket/blame/master/pkgs/base/info.rkt, the version number was bumped
> away from 6.7.0.3 in commit d7b18e7, so you could try checking out the
> previous commit (5e94a90) and compiling that. Racket isn't very difficult
> to compile under Linux, never tried on Windows, so good luck :) !
>
> PS: Don't forget to report that new bug if you haven't already, sometimes
> they are fixed within hours.

-- 
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] hello, where can I find the distribution 6.7.0.3.

2017-01-04 Thread WarGrey Gyoudmon Ju
I cannot deploy my typed desktop application on Windows.

In the download home page, 6.7 does not work, and that bug seemed to be
solved (I started 6.7 from 6.7.0.3, do not know whether it was okay on
macOS).

The latest snapshot has a new bug shown both on macOS and Windows:

in-list: contract violation
  expected: list?
  given: (hash (Object) #t b #t)
  compilation context...:
context...:
   C:\Program Files\Racket-6.7.0.4\collects\racket\private\for.rkt:633:2:
in-list
   f184
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\type-rep.rkt:656:4:
for-loop
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\type-rep.rkt:653:0:
Union-map
   f152
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\rep\rep-utils.rkt:191:8:
Rep-fmap
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-subst.rkt:98:0:
subst-tc-result
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-subst.rkt:35:0:
values->tc-results5
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-funapp.rkt:45:0:
tc/funapp
   temp101
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-expr-unit.rkt:329:0:
core914
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-if.rkt:13:0:
core16
   temp101
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-expr-unit.rkt:326:0:
tc-expr
   temp101
   C:\Program
Files\Racket-6.7.0.4\share\pkgs\typed-racket-lib\typed-racket\typecheck\tc-expr-unit.rkt:79:0:
tc-expr/check
   ...

Would you please take me to the download page of 6.7.0.3? or one commit
before this bug? (I don't want to build it from source because real users
of this application have no knowledge on programming. Also I am working
remotely, we should have an agile feedback and update process). Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Good Data Structures Book?

2016-12-14 Thread WarGrey Gyoudmon Ju
"Pearls of Functional Algorithm Design"
https://www.amazon.com/Pearls-Functional-Algorithm-Design-Richard/dp/0521513383/ref=sr_1_1

The functional "programming pearls" in Haskell, but the author prefers the
term "algorithm design".


On Wed, Dec 14, 2016 at 2:48 AM, Ben Greenman 
wrote:

> "Purely Functional Data Structures"
> https://www.amazon.com/Purely-Functional-Structures-Chris-
> Okasaki/dp/0521663504
>
> On Tue, Dec 13, 2016 at 1:22 PM, Lawrence Bottorff 
> wrote:
>
>> Can someone suggest a good text for data structures that would compatible
>> with Racket? All I see are treatments using C/C++, Java, Python, i.e., the
>> usual suspects. Or, how do you people at Racket-friendly/based universities
>> teach undergrad data structures?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Adding new exceptions

2016-11-29 Thread WarGrey Gyoudmon Ju
Hi, David.

The exn:fail:filesystem and exn:fail:network do provide the errno code, If
you are only working in one OS, you can also rely on the errno code. If you
are working on multiple OSes, it might be a problem since Racket have not
yet provided an abstract layer on the errno code.

If you prefer to detect the error type via (exn-message), that would be
fine for Racket, I do not think Racket will change the messages unless your
OS change its standard c library.


On Tue, Nov 29, 2016 at 1:18 PM, David Storrs 
wrote:

> After sending this I realized that I could define my own exception types
> and use those.  The original question, though, was how to get the built-in
> exception hierarchy expanded into something more fine-grained.
>
> On Mon, Nov 28, 2016 at 7:46 PM, David Storrs 
> wrote:
>
>> I'm doing some "write files to disk" work and noticing that the exception
>> system for the filesystem isn't terribly fine-grained.  Leaving aside
>> exceptions that pertain to Racket's module system we only have:
>>
>> exn:fail:filesystem   (something went wrong in general)
>> and
>> exn:fail:filesystem:exists?  (you tried to create a file that already
>> exists)
>>
>> If I'm, e.g. using rename-file-or-directory and it fails I need to parse
>> the actual message string to know what went wrong:
>>
>> (define msg (exn-message e)) ;; assume we're in a handler
>> (cond [(regexp-match #px"No such file or directory" msg) ...]
>>   [(regexp-match #px"the destination file already exists" msg)
>> ...])
>>
>> This is verbose, error-prone, and vulnerable to changes in the messages
>> that could happen in future versions of Racket.
>>
>> I would prefer to have exception types that deal with this -- for example:
>>
>> exn:fail:filesystem:source-not-found
>> exn:fail:filesystem:target-exists
>>
>>
>> What would be involved in doing this?  Should I be filing a feature
>> request on Github?
>>
>
> --
> 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] Request for comments: An embedded DSL for CSS in Racket

2016-11-13 Thread WarGrey Gyoudmon Ju
I have been writing my CSS engine.

[sorry this reply might be a little off-topic here]

Long period before, someone in this mailing list asked if their are user
editable configuration file formats that can be used in real world
applications. `info.rkt` might be a choice but it is not designed for the
purpose. Finally I choose the syntax of CSS to achieve the goal because it
is elegant and expressive enough, although I cannot say I like it, it is
the only choice for web front-end guys.

As I have mentioned before, Scribble has already acted as a great and
powerful preprocessor, I think therefore there is no much necessary to
write a CSS front-end with s-exp looking in practice.

At the beginning of the task, I have struggled to work with the syntax
object (yes, it is one of the core essentials that make Racket different),
however it is hard to trace the datatypes of CSS itself (and
case-sensitivity), this is even more painful in Typed Racket. Thus, I think
write my own parser along with datatypes and exn trees is a better choice.

Meanwhile I have finished the engine of CSS syntaxes, grammars and
computation modeling(which is the supplement of what CSS preprocessors do),
and trying to make CSS interact with Racket efficiently. BTW, CSS is not
good architected as a programming language, I am not sure if I would keep
following their specs(I mean the language parts, I don't care the applied
parts), it is becoming too complicated but does not make much sense.

One of the major reasons I started this project is I need an expressive way
to describe (desktop) applications in Racket, maybe in the future I will
release a CSS-based GUI frameworks. Finally I still need to find a more
efficient computation model because this engine is running in the runtime,
after upgrading to Racket 6.7, it's surprisingly slower than before...

On Fri, Oct 28, 2016 at 3:17 AM,  wrote:

> Hi, all.
>
> I am working on an embedded DSL for CSS in Racket. I want to get feedback
> from
> the community regarding the project’s goals and my choice of tools for
> implementing it.
>
>
> LANGUAGE
>
> I want to use Racket to generate CSS for me. I am not interested in a
> “#lang”
> language, but in a DSL that lives embedded in the code. In particular, I
> want
> “quote” and “unquote”. The best I can think of is something like:
>
>   (define main-background-color #'red)
>   (define the-css
> #`([body #:background-color #,main-background-color]))
>   (css-expr->string the-css) ;; => "body{background-color:red;}"
>
> Note the explicit use of syntax objects. They allow for arbitrary “quote”
> and
> “unquote” and preserve source location information, which improves the
> quality
> of error messages. This is the best solution I could find, but I recognize
> it is
> unusual—I cannot name a single other example of embedded DSL in Racket that
> operates with syntax objects directly. Can you think of something better?
>
>
> COMPILER FRONT END
>
> I want good error messages, so I am using “syntax-parse”. I defined the
> concrete
> syntax tree in terms of syntax classes—each production rule on the
> context-free
> grammar for the concrete syntax tree is a “syntax-parse” syntax class. For
> example, the following defines a “stylesheet” as a list of “rules”:
>
>   (define-syntax-class stylesheet
> (pattern (rule:rule ...)))
>
> The abstract syntax tree are typed structs, because I want to benefit from
> the
> correctness guarantees of Typed Racket. For example, the following is a
> struct
> for “stylesheets”:
>
>   (struct stylesheet ([rules : (Listof rule)]) #:transparent)
>
> Then, the parser uses “syntax-parse” with the syntax classes to generate
> the
> typed structs. For example, the following is a parser rule for
> “stylesheets”:
>
>   (define (parse/stylesheet expression)
> (syntax-parse expression
>   [stylesheet:stylesheet
>(extended:stylesheet (map parse/rule
>  (syntax->list #'(stylesheet.rule
> ...]))
>
> With this approach, I get a combination of good parsing error messages and
> typed
> structures to work on the compiler back end. But there is no
> “syntax-parse” in
> Typed Racket, so the parser module must be untyped. The interaction between
> untyped (compiler front end) and typed (compiler back end) modules leads to
> performance penalties. Overall, the whole architecture feels awkward, I
> feel
> like I am fighting the tools. Can you think of a better solution?
>
>
> COMPILER BACK END
>
> I use the typed structures in a module that concatenates strings to form
> CSS. This is the part I am happiest about, but I accept suggestions of more
> principled approaches than carefully constructed calls to “string-append”
> and
> “string-join”.
>
>
> OPINION
>
> My inspiration were the DSLs from http://www.cliki.net/CSS. I could not
> find a
> Racket equivalent. The following is an example of what the language looks
> like,
> recreating the CSS from 

Re: [racket-users] Re: What is the fastest way to find the total free space on the disk?

2016-11-13 Thread WarGrey Gyoudmon Ju
I have written one in my project
this task varies both from OS and filesystem.

https://github.com/digital-world/sakuyamon/blob/master/digitama/posix.c
It works on Solaris/Linux/MacOSX, and collects more sysinfo metrics than
just disk usage.

`ffi_prefab_ksysinfo` is the main struct, and `system_statistics` is the
entrance.
You have to write your own FFI wrapper since currently I am busy in another
project
and that one is bad architected.


On Fri, Nov 4, 2016 at 1:18 AM, David Storrs  wrote:

>
>
> On Thu, Nov 3, 2016 at 12:58 PM, Ethan Estrada 
> wrote:
>
>> On Wednesday, November 2, 2016 at 12:20:12 PM UTC-6, David K. Storrs
>> wrote:
>> > I've been looking through the docs for how to check available disk
>> space.  I looked in the  filesystem and os libraries and I threw keywords
>> at the search tool, but I can't find an answer.
>> >
>> > I'm looking for the equivalent of the Unix / OSX "df" command.  I could
>> shell out and parse the output, I suppose, but that seem unportable and
>> error prone.  Is there a builtin for it?
>>
>> I don't know of anything builtin or in the official package repo to do
>> this. Your best short term bet is probably using the kluge you came up
>> with: shelling out to the "df" command and parsing the output.
>>
>> However, it sounds like this functionality is something that could
>> eventually be abstracted into a module using native system libraries and
>> FFI. It would mostly be a research project to find out which system
>> libraries one would need. If I had more time right now, I'd work on it
>> myself to get more hands on racket experience.
>>
>>
> Okay, good to know.  Thanks!
>
>
>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Twenty six low-risk ways to use Racket at work You can start right now

2016-09-30 Thread WarGrey Gyoudmon Ju
Hi spdegabrielle, no apologies please.

Actually, I did not or probably could not make myself clearly when I wrote
that reply. I had felt depressed since this mail-list is not as active as
before. At the first sight I saw your topic, I thought there should be more
topics like this, but not only concentrate on the low-risk tasks, to help
others (especially new members) understand Racket and its ability, because
sometimes they ask "does Racket fit their task" but get less answers...
Besides,  I think lot's of members in the community are not the typical
programmers, they have special knowledge other than programming, and they
also use Racket to deal with their work, all these situations could be
count in.

Never mind, let's get back on topic. I added two low-risk ways that fit
Racket's sweet spot because Scribble is the greatest documentation tool, I
use it to generate high quality docs in the real world projects, some other
interesting tasks, such as unit testing, diagramming or visualization, are
integrated with it seamlessly. As a programmable programming language,
Racket also provides lots of ways to cowork with other languages, one way
is, say, front-end guys make a lot of alternatives to CSS to overcome its
weakness, working with Racket as a preprocessor, all those alternatives are
useless.

I like talking about the documentation, one reason is that other low-risk
tasks are talked too much by wide programmers; the other reason is that, I
like the idea behind the Racket and Scribble. Actually I think the docs of
the main distribution is already a great example, entries are organized
compactly, each entry focus on one topic, no duplicates, contents are made
with simple examples, most of them are trying to talk with readers,
 although it may too verbose as a wiki page.

Currently I am working for a startup as a full-stack Racket developer, but
it is not a computer or internet project, everything needs to be setup.
Okay, wordy again. :P

On Fri, Sep 30, 2016 at 6:52 PM, spdegabrielle 
wrote:

> OK I've started with: https://github.com/racket/
> racket/wiki/Low-risk-ways-you-can-use-Racket-at-work
>
> Please feel free to edit/delete/move/rearrange as you see fit.
>
> S.
>
> PS Davids thing sounds awesome!
> PPS I'm sorry Ju. Please accept my apologies - I don't understand your
> response. Can you try again?
>
> On Thursday, September 29, 2016 at 3:57:19 PM UTC+1, Matthias Felleisen
> wrote:
> > Do you mean to write a Racket version for this? I think that would be
> amazing!
> >
> >
> >
> > > On Sep 29, 2016, at 4:43 AM, Stephen De Gabrielle <
> spdegabrie...@gmail.com> wrote:
> > >
> > > Hi all,
> > >
> > > I was listening to a podcast about F# That mentioned an article like
> this
> > > As I've used a racket at work a number of times for small job, it
> occurs to me that this might be a nice thing to pop on the wiki. Please let
> me know if you have any objections.
> > >
> > > Kind regards,
> > >
> > > Stephen
> > >
> > > Ref https://fsharpforfunandprofit.com/posts/low-risk-ways-to-
> use-fsharp-at-work/
> > > --
> > > Kind regards,
> > > Stephen
> > > --
> > > Bigger than Scheme, cooler than Clojure & more fun than CL.(n=1)
> > > --
> > >
> > > --
> > > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Twenty six low-risk ways to use Racket at work You can start right now

2016-09-29 Thread WarGrey Gyoudmon Ju
27. Racket is in the nature of a preprocessor;
28. Besides the literate programming, Racket is a "programmable
documentation".

Any point in the two (and those 26) is not as good as it's sound if it's
not the important part in the project or team. However if all of these can
work together in a systematic way, that will be an amazing practical way, I
think Racket steps a bit far than other (mainstream-or-not) languages.
Okay, this is another story, I am making myself towards this goal at work.

Basically, I am not interested in talking about these auxiliary tasks since
all these tasks can be done by any general purpose languages, even by a
prolog implementation with FFI. I am not sure what are the high-risk ways,
 probably they are related to time-limited tasks, that is the true problem.
Or, any experts, writers, lecturers, designers, kids' teachers,
researchers, and so on, can use Racket to have their scriptable work done
as long as "programmer" is not their unique/major title.

By the way, it was a long period that there are no Know-Racket topics like
this in the list, do they struggling with the high-risk tasks? :p

On Thu, Sep 29, 2016 at 4:43 PM, Stephen De Gabrielle <
spdegabrie...@gmail.com> wrote:

> Hi all,
>
> I was listening to a podcast about F# That mentioned an article like this
> As I've used a racket at work a number of times for small job, it occurs
> to me that this might be a nice thing to pop on the wiki. Please let me
> know if you have any objections.
>
> Kind regards,
>
> Stephen
>
> Ref https://fsharpforfunandprofit.com/posts/low-risk-ways-to-
> use-fsharp-at-work/
> --
> Kind regards,
> Stephen
> --
> Bigger than Scheme, cooler than Clojure & more fun than CL.(n=1)
> --
>
> --
> 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] Is it neccessary to learn how to define new language?

2016-09-19 Thread WarGrey Gyoudmon Ju
On Mon, Sep 19, 2016 at 3:12 PM, Lin Lee  wrote:

> I'm a newcomer to Racket,I have learned scheme before.
>
> Recently,I began to learn Racket,but I found that it's too complicate in
> reader and expander. So,I want to know what if i dont learn this part.Does
> it do harm to me?
>
> Any suggestion is helpful. tks


This is one of the core part what Racket is.
So, if you mean learning it the academic way, there is no reason to bypass
it.
If you mean learning to build practical applications, it depends,
nonetheless, you will not lose anything without that knowledge.

-- 
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] Vector or array type for math vector?

2016-09-16 Thread WarGrey Gyoudmon Ju
No, Racket's vector is an array from Java's perspective(int [] for
instance), not a custom data structure,
Array is not a builtin datatype in Racket.

If working with math-lib, you already have linear algebra supported.
the array in math/array is a custom data structure with vector in heart.

On Fri, Sep 16, 2016 at 9:39 AM, Lawrence Bottorff 
wrote:

> I'm trying out some of the math capabilities of Racket and I'm guessing
> the linear algebra concept of a vector is actually an Array type in Racket,
> not a Vector. Is this correct? Racket's Vector is a data (as with Java's
> Vector) structure, right?
>
> --
> 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] typed racket confusion

2016-09-09 Thread WarGrey Gyoudmon Ju
Because in function `b`, the type of the `lambda` that `n` actually be
passed to is the union of `add1` and `sub1` in the context,
hence, the info on parity of `n` are lost before this `lambda` is evaluated.

On Sat, Sep 10, 2016 at 3:42 AM, Jos Koot  wrote:

> #lang typed/racket
>
> (define (a (n : Exact-Nonnegative-Integer)) : Exact-Nonnegative-Integer
>  (if (even? n) (add1 n) (sub1 n)))
>
> (define (b (n : Exact-Nonnegative-Integer)) : Exact-Nonnegative-Integer
>  ((if (even? n) add1 sub1) n))
>
> Function a goes well,
> but function b gives an error during expansion:
>
> Type Checker: type mismatch
>   expected: Nonnegative-Integer
>   given: Integer in: ((if (even? n) add1 sub1) n)
>
> Apparently the type checker deduces that in function a,
> sub1 will not be applied to zero.
> Why it can't also detect this for function b?
>
> Thanks, Jos
>
> --
> 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] Scaling image with racket/draw?

2016-08-31 Thread WarGrey Gyoudmon Ju
Oh sorry, I have not tried that deep.
Racket logos and icons are also scaled in this way.
So for everyday tasks, I think this implementation is good enough
especially the backing-scale is taken care.
It's better than APIs in flomap and pict.

BTW, It's a long period that no one maintains the flomap library. What a
pity!

On Thu, Sep 1, 2016 at 4:40 AM, Jens Axel Søgaard <
jensaxelsoega...@gmail.com> wrote:

> Is the result as good as ImageMagick?
>
> Den 31. aug. 2016 kl. 22.25 skrev Tobias Gerdin <tger...@gmail.com>:
>
> Right, that did it, thanks!
>
> 2016-08-31 14:19 GMT+02:00 WarGrey Gyoudmon Ju <juzhenli...@gmail.com>:
>
>> Try this example,
>>
>> (require racket/draw)
>>
>> (define bitmap-blank
>>   (lambda [[w 0] [h #false] #:backing-scale [backing-scale 2.0]]
>> (define width  (max 1 (exact-ceiling w)))
>> (define height (max 1 (exact-ceiling (or h w
>> (make-bitmap width height #:backing-scale backing-scale)))
>>
>> (define bitmap-scale
>>   (case-lambda
>> [(bmp scale)
>>  (if (= scale 1.0) bmp (bitmap-scale bmp scale scale))]
>> [(bmp scale-x scale-y)
>>  (cond [(and (= scale-x 1.0) (= scale-y 1.0)) bmp]
>>[else (let ([w (max 1 (exact-ceiling (* (send bmp get-width)
>> scale-x)))]
>>[h (max 1 (exact-ceiling (* (send bmp get-height)
>> scale-y)))])
>>(define dc (make-object bitmap-dc% (bitmap-blank w h)))
>>(send dc set-smoothing 'aligned)
>>(send dc set-scale scale-x scale-y)
>>(send dc draw-bitmap bmp 0 0)
>>(or (send dc get-bitmap) (bitmap-blank)))])]))
>>
>> I use it in my project.
>> The algorithm is exact what Jens says.
>>
>> On Wed, Aug 31, 2016 at 5:17 AM, Jens Axel Søgaard <jensa...@soegaard.net
>> > wrote:
>>
>>> Hi Tobias,
>>>
>>> I call the below procedure with `in` equal to a 1300-pixel wide PNG
>>>> image, w=320 and `out` equal to a nice path. Even so, the `out` image
>>>> remains 1300 pixels wide (i.e. it's not resized).
>>>>
>>>> (define (racket-resize in w out)
>>>>   (let ([bitmap (read-bitmap in)])
>>>> (let ([orig-width (send bitmap get-width)])
>>>>   (let ([dc (send bitmap make-dc)]
>>>> [s (/ w orig-width)])
>>>> (send dc scale s s))
>>>>   (send bitmap save-file out 'png
>>>>
>>>> What am I doing wrong?
>>>>
>>>
>>> The problem is that scale doesn't change the bitmap.
>>> The scale affects how the logical coordinates of the drawing context
>>> are translated into bitmap coordinates.
>>>
>>> In order to resize a bitmap:
>>>
>>>1. Create a new bitmap with the new size.
>>>2. Get the dc for the new bitmap
>>>3. Set the scale of dc
>>>4. Use draw-bitmap using the old image as the source
>>>5. Save the new bitmap
>>>
>>> (untested)
>>>
>>> /Jens Axel
>>>
>>>
>>>
>>>
>>> --
>>> 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] Scaling image with racket/draw?

2016-08-31 Thread WarGrey Gyoudmon Ju
Try this example,

(require racket/draw)

(define bitmap-blank
  (lambda [[w 0] [h #false] #:backing-scale [backing-scale 2.0]]
(define width  (max 1 (exact-ceiling w)))
(define height (max 1 (exact-ceiling (or h w
(make-bitmap width height #:backing-scale backing-scale)))

(define bitmap-scale
  (case-lambda
[(bmp scale)
 (if (= scale 1.0) bmp (bitmap-scale bmp scale scale))]
[(bmp scale-x scale-y)
 (cond [(and (= scale-x 1.0) (= scale-y 1.0)) bmp]
   [else (let ([w (max 1 (exact-ceiling (* (send bmp get-width)
scale-x)))]
   [h (max 1 (exact-ceiling (* (send bmp get-height)
scale-y)))])
   (define dc (make-object bitmap-dc% (bitmap-blank w h)))
   (send dc set-smoothing 'aligned)
   (send dc set-scale scale-x scale-y)
   (send dc draw-bitmap bmp 0 0)
   (or (send dc get-bitmap) (bitmap-blank)))])]))

I use it in my project.
The algorithm is exact what Jens says.

On Wed, Aug 31, 2016 at 5:17 AM, Jens Axel Søgaard 
wrote:

> Hi Tobias,
>
> I call the below procedure with `in` equal to a 1300-pixel wide PNG image,
>> w=320 and `out` equal to a nice path. Even so, the `out` image remains 1300
>> pixels wide (i.e. it's not resized).
>>
>> (define (racket-resize in w out)
>>   (let ([bitmap (read-bitmap in)])
>> (let ([orig-width (send bitmap get-width)])
>>   (let ([dc (send bitmap make-dc)]
>> [s (/ w orig-width)])
>> (send dc scale s s))
>>   (send bitmap save-file out 'png
>>
>> What am I doing wrong?
>>
>
> The problem is that scale doesn't change the bitmap.
> The scale affects how the logical coordinates of the drawing context
> are translated into bitmap coordinates.
>
> In order to resize a bitmap:
>
>1. Create a new bitmap with the new size.
>2. Get the dc for the new bitmap
>3. Set the scale of dc
>4. Use draw-bitmap using the old image as the source
>5. Save the new bitmap
>
> (untested)
>
> /Jens Axel
>
>
>
>
> --
> 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] Help needed in file processing idioms

2016-08-20 Thread WarGrey Gyoudmon Ju
see docs for (read-line)

On Sat, Aug 20, 2016 at 5:16 PM, Pekka Niiranen <pekka.niira...@pp5.inet.fi>
wrote:

> Thank you guys,
>
>
> both functions work. Looks like single function (for/or) could be used
> if the calling side handles #f, #t and a list.
>
> Another issue:
>
> I am planning to support both Unix and Windows, but have not found
> a way to define 'return-linefeed as system-wide default (aside using
> global variable):
> Whenever one does file-I/O; 'return-linefeed is used as newline.
> I do like not to be forced to give the 3rd parameter (return-linefeed)
> like below
>
> (in-lines inp 'return-linefeed)
>
> -pekka-
>
> On 20/08/16 02:47, Gustavo Massaccesi wrote:
> > Minor fix: In the first function "read-on-row" you must replace
> > for/first with for/last.
> >
> > Gustavo
> >
> > PS for Pekka: In this case it's better to use for/last and for/or, but
> > in more complicated cases you can try with for/fold.
> >
> >
> > On Fri, Aug 19, 2016 at 10:34 AM, WarGrey Gyoudmon Ju
> > <juzhenli...@gmail.com> wrote:
> >> (define (read-on-row *params*)
> >>;; Returns the last line in "myfile" which contains
> >>;; substring "ON", otherwise #f
> >>(call-with-input-file (hash-ref *params* "myfile")
> >>  (lambda (inp)
> >>(for/first ([row (in-lines inp 'return-linefeed)]
> >>#:when (string-contains? row "ON"))
> >>   row
> >>
> >> (define (on-row-exists *params*)
> >>;; Returns #t if there is line in "myfile" which contains
> >>;; substring "ON", otherwise #f
> >>(call-with-input-file (hash-ref *params* "myfile")
> >>  (lambda (inp)
> >>(for/or ([row (in-lines inp 'return-linefeed)])
> >>(string-contains? row "ON")
> >>
> >>
> >> On Fri, Aug 19, 2016 at 9:18 PM, Pekka Niiranen <
> pekka.niira...@pp5.inet.fi>
> >> wrote:
> >>> Hello users,
> >>>
> >>> I would like to read lines from a file, process each line
> >>> and return either the success of the operation or the processed line to
> >>> another function located in another module.
> >>>
> >>> Below are two functions that work OK, but are in my opinion "ugly"
> because
> >>> they use "set!".
> >>>
> >>> It there a way to make both functions work without "set!"?
> >>>
> >>>
> >>> ;;
> >>> (define (read-on-row *params*)
> >>> ;; Returns the last line in "myfile" which contains
> >>> ;; substring "ON", otherwise #f
> >>>
> >>>(define pdata #f) ;; I do not like this extra variable!
> >>>
> >>>(call-with-input-file (hash-ref *params* "myfile")
> >>>  (lambda (inp)
> >>>(for/last ([row (in-lines inp 'return-linefeed)]
> >>>   #:when (string-contains? "ON" row))
> >>>  (set! pdata row
> >>>
> >>>pdata)
> >>>
> >>> ;;
> >>>
> >>> (define (on-row-exists *params*)
> >>> ;; Returns #t if there is line in "myfile" which contains
> >>> ;; substring "ON", otherwise #f
> >>>
> >>>(define found-on #f) ;; I do not like this extra variable!
> >>>
> >>>(call-with-input-file (hash-ref *params* "myfile")
> >>>  (lambda (inp)
> >>>(for/last ([row (in-lines inp 'return-linefeed)]
> >>>   #:when (string-contains? "ON" row))
> >>>  (set! found-on #t
> >>>
> >>>found-on)
> >>>
> >>> -pekka-
> >>>
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "Racket Users" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an
> >>> email to racket-users+unsubscr...@googlegroups.com.
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups
> >> "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an
> >> email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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] Help needed in file processing idioms

2016-08-19 Thread WarGrey Gyoudmon Ju
(define (read-on-row *params*)
  ;; Returns the last line in "myfile" which contains
  ;; substring "ON", otherwise #f
  (call-with-input-file (hash-ref *params* "myfile")
(lambda (inp)
  (for/first ([row (in-lines inp 'return-linefeed)]
  #:when (string-contains? row "ON"))
 row

(define (on-row-exists *params*)
  ;; Returns #t if there is line in "myfile" which contains
  ;; substring "ON", otherwise #f
  (call-with-input-file (hash-ref *params* "myfile")
(lambda (inp)
  (for/or ([row (in-lines inp 'return-linefeed)])
  (string-contains? row "ON")


On Fri, Aug 19, 2016 at 9:18 PM, Pekka Niiranen 
wrote:

> Hello users,
>
> I would like to read lines from a file, process each line
> and return either the success of the operation or the processed line to
> another function located in another module.
>
> Below are two functions that work OK, but are in my opinion "ugly" because
> they use "set!".
>
> It there a way to make both functions work without "set!"?
>
>
> ;;
> (define (read-on-row *params*)
> ;; Returns the last line in "myfile" which contains
> ;; substring "ON", otherwise #f
>
>   (define pdata #f) ;; I do not like this extra variable!
>
>   (call-with-input-file (hash-ref *params* "myfile")
> (lambda (inp)
>   (for/last ([row (in-lines inp 'return-linefeed)]
>  #:when (string-contains? "ON" row))
> (set! pdata row
>
>   pdata)
>
> ;;
>
> (define (on-row-exists *params*)
> ;; Returns #t if there is line in "myfile" which contains
> ;; substring "ON", otherwise #f
>
>   (define found-on #f) ;; I do not like this extra variable!
>
>   (call-with-input-file (hash-ref *params* "myfile")
> (lambda (inp)
>   (for/last ([row (in-lines inp 'return-linefeed)]
>  #:when (string-contains? "ON" row))
> (set! found-on #t
>
>   found-on)
>
> -pekka-
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: How to differentiate between files and directories?

2016-07-21 Thread WarGrey Gyoudmon Ju
Maybe you can work with (namespace-mapped-symbols) and
(namespace-variable-value),
All field accessors are procedures with name starts with "struct-name-", no
duplicates in the entire application.

On Fri, Jul 22, 2016 at 3:59 AM, David Storrs 
wrote:

> So there's no way to query the interface of a struct?
>
>
> On Thursday, July 21, 2016, Jon Zeppieri  wrote:
>
>>
>>
>> On Thu, Jul 21, 2016 at 2:44 PM, David Storrs 
>> wrote:
>>>
>>>
>>>
>>> In a related question, is there a way to introspect a struct to find
>>> out what its fields are?
>>>
>>>
>> If you mean the field values: yes, but only if the struct is transparent
>> or prefab or if you have the proper inspector, which you probably do not.
>> You can generally try struct->vector and see if you get anything useful.
>>
>> If you mean the field names: I don't think so; I don't think they exist
>> at runtime.
>>
>> - Jon
>>
>>
>>
> --
> 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 when intalling racket 6.5 in solaris (a sparc machine)

2016-06-29 Thread WarGrey Gyoudmon Ju
Also, you may want '--disable-libffi'

On Thu, Jun 30, 2016 at 11:11 AM, Matthew Flatt  wrote:

> I'm not sure, but it's possible that a newer version of libtool is
> needed.
>
> Meanwhile, does dropping the `--enable-shared` flag help? (I recommend
> that in any case, unless you specifically need a libracket shared
> library.)
>
> At Wed, 29 Jun 2016 22:33:59 -0400, HP Wei wrote:
> > I replaced ‘-KPIC’ with ‘-fPIC’ in all instances in the files that you
> listed.
> >
> > Start from a new build/;  configure … ; make —>  still get the same
> error.
> >
> > Then after the above failure, I noticed:
> >libtool —config | grep pic_flag
> > pic_flag= “ -KPIC -DPIC”
> >   libtool —config | grep CC
> > CC=“cc”
> >
> > So, something is not right with these configuration variables.
> > I am not familiar with libtool.
> > And I tried to set
> > export CC=gcc
> > export pic_flag=“ -fPIC -DPIC”
> > These did not help.
> >
> > Any suggestions ?
> > hp
> >
> >
> > > On Jun 29, 2016, at 8:43 PM, George Neuner 
> wrote:
> > >
> > >
> > > On 6/29/2016 6:00 PM, hpwe...@gmail.com 
> wrote:
> > >> I downloaded racket 6.5 sources
> > >> to a Sun's Sparc machine running Solaris (SunOS 5.11)
> > >> gcc version = 4.8.1
> > >>
> > >> in the build directory, I did these two steps:
> > >> ../configure --prefix=/a/path --enable-shared
> > >> make
> > >>
> > >> --> It exited with the following error message:
> > >>
> > >> cd sgc; make ../libmzgc.la
> > >> make[7]: Entering ... build/racket/sgc'
> > >> libtool --mode=compile ... -o sgc.lo
> > >> mkdir .libs
> > >>   gcc -Wall ... -KPIC -DPIC -c .../sgc.c -o .libs/sgc.o
> > >> gcc: error: unrecognized command line option '-KPIC'
> > >> ...
> > >>
> > >> I tried to look for where the option '-KPIC' was located in
> > >> the Makefiles --> but I could not find it.
> > >>
> > >> Any idea what happened and how I can proceed ?
> > >>
> > >> thanks
> > >> HP
> > >
> > > Back in the 90's I worked with SunOS5/Solaris, but this is a new one
> for
> > me.   :-)
> > >
> > > A little searching turned up that -KPIC / -Kpic  tells the Sun C
> compiler to
> > produce position independent code - the case of the flag determines the
> > maximum size of the global offset table.The equivalent GCC flags are
> -fPIC
> > / -fpic ... you *might* be able to get away with fixing up the
> makefile(s), if
> > there are no other CC specific options.   Otherwise, you can try
> changing the
> > configuration files [below] in the sections pertaining to Solaris and/or
> > SunOS, and then run configure again to start over.
> > >
> > > A grep of the [full] 6.5 release sources found the  -KPIC option
> referenced
> > in the following files:
> > >
> > > racket-6.5\src\foreign\libffi\configure
> > > racket-6.5\src\foreign\libffi\m4\libtool.m4
> > > racket-6.5\src\lt\aclocal.m4
> > > racket-6.5\src\lt\configure
> > > racket-6.5\src\racket\gc\configure
> > > racket-6.5\src\racket\gc\doc\README.DGUX386
> > > racket-6.5\src\racket\gc\libtool.m4
> > >
> > >
> > > Obviously the Racket build maintainers will have to fix this at the
> > configuration level.
> > >
> > > Hope this helps,
> > > George
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] [racket][typed] infinite typechecking

2016-06-28 Thread WarGrey Gyoudmon Ju
Hello,

This is version 6.5.0.5.

(define-syntax (define-tokens stx)
  (syntax-case stx []
[(_ token
#:+ Token (extra ...)
#:with [[subtoken #:+ SubToken subrest ...] ...]
[id #:+ ID #:-> parent #:as Type rest ...] ...)
 (with-syntax ([token->datum (format-id #'token "~a->datum" (syntax-e
#'token))]
   [([id? id-datum] ...) (for/list ([ (in-list
(syntax->list #'(id ...)))])
   (list (format-id  "~a?"
(syntax-e ))
 (format-id  "~a-datum"
(syntax-e ])
   #'(begin (struct: token : Token ([source : Any] [line : Natural]
[column : Natural]
   [position : Natural]
[span : Natural] extra ...))
(struct: subtoken : SubToken subrest ...) ...
(define-token id #:+ ID #:-> parent #:as Type rest ...) ...

(define token->datum : (-> Token Datum)
  (lambda [instance]
(cond [(id? instance) (id-datum instance)] ...
  [else (assert (object-name instance)
symbol?)])]))

The following code is okay, however, if more definitions are added, then
the typechecking will refuse to terminate itself.

(define-tokens css-token
  #:+ CSS-Token ()
  #:with [[css:numeric #:+ CSS:Numeric css-token ([representation :
String])]
  [css:number #:+ CSS:Number css:numeric ()]]
  [css:bad  #:+ CSS:Bad #:-> css-token #:as Datum]
  [css:close #:+ CSS:Close #:-> css-token #:as Char]
  [css:cd #:+ CSS:CD #:-> css-token #:as Symbol]
  [css:match #:+ CSS:Match #:-> css-token #:as Char]
  [css:ident #:+ CSS:Ident #:-> css-token #:as Symbol]
  [css:url #:+ CSS:URL #:-> css-token #:as String]
  [css:function #:+ CSS:Function #:-> css-token #:as Symbol])

The attachment contains the full example to run.
Thanks.

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


infinite-typechecking.rkt
Description: Binary data


Re: [racket-users] DrRacket debugger error

2016-05-11 Thread WarGrey Gyoudmon Ju
Just mention here:
I met this error message when invoking a function with keyword arguments
within the class body (but not method body).
The simplest solution is to wrap the function application in another
function that do not passed with keyword arguments.

(define toolbar-snip% : Toolbar-Snip%
  (class snip% (super-new)
(init-field src tips)

; WARNING: If (f) is invoked with #:keyword arguments,
;Typed Racket will complains "Cannot Use
Identifier Tainted by Macro Transformation".
; WORKAROUND:  Wrapping (f) in another s-exp will solve it.
(define face.icon : Bitmap (values (bitmap src #:height
toolbar-icon-size

On Wed, May 11, 2016 at 10:32 AM, copycat  wrote:

> I get the following error:
>
> module: cannot use identifier tainted by macro transformation in: module
>
> when i try to debug a multi-file program with both untyped and typed
> scripts in it. If it's just untyped scripts it will work fine.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: Accessing Undo/Redo History directly?

2016-04-19 Thread WarGrey Gyoudmon Ju
I think it's impossible to access written texts since what inside the
undo/redo history are functions, not the content entities.
So you have to manage texts on your own.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] [racket][typed] static-contracts/instantiate.rkt:64:2. car: contract violation.

2016-04-18 Thread WarGrey Gyoudmon Ju
On Mon, Apr 18, 2016 at 4:03 AM, Asumu Takikawa <as...@ccs.neu.edu> wrote:

> On 2016-04-18 03:47:45 +0800, WarGrey Gyoudmon Ju wrote:
> >And here is another question. Developing GUI Application involves
> typed
> >class system heavily, which makes the compiling time terribly long (if
> >this is the root cause).
>
> It's possible that typed classes are slowing down typechecking, in
> particular
> typechecking methods can be slow. (I think this is in part because Typed
> Racket has to fold over entire types, and class types can be large)
>
> The typechecker for classes actually has some performance logging (that's
> disabled by default):
>
>
> https://github.com/racket/typed-racket/blob/master/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt#L37
>
> which you could try turning on to see what's slow. (you will have to
> capture
> the log output, e.g., by setting the PLTSTDERR environment variable)
>


> Also if you send me some self-contained code that's particularly slow to
> typecheck I can look into it too.
>
> We don't have a global flag to turn off typechecking right now. I think the
> best thing for us to do is to try to make TR faster.
>

That's worth expecting.

The typed class system as a root cause is no more special other than its
essential complexity, and the long-time-delays occur in these three
situations every compiling:

1. It's glad to see typechecking methods is not the problem, and it's never
longer than one second.

racket: TR class time @ done: 136.580078125
racket: tr-timing: pass2 #false line #false at 124557 last
step: 135 gc: 3 total: 1535
racket: tr-timing: pass2 timon/nefertimon.rkt line 75   at 124557 last
step: 0 gc: 0 total: 1535
racket: tr-timing: Finished pass2   at 124557 last
step: 0 gc: 0 total: 1535
racket: online-check-syntax: TR's tooltip syntaxes; this message is ignored
racket: tr-timing: finished provide generation  at 124667 last
step: 110 gc: 0 total: 1645
racket: tr-timing: finished type checking   at 124667 last
step: 0 gc: 0 total: 1645
racket: tr-timing: Typechecking Doneat 124667 last
step: 0 gc: 0 total: 1645
racket: tr-timing: Removed provides at 124667 last
step: 0 gc: 0 total: 1645
racket: tr-timing: Fixed contract ids   at 124667 last
step: 0 gc: 0 total: 1645

racket: tr-timing: Generated contracts  at 135670 last
step: 11003 gc: 427 total: 12648
racket: tr-timing: Starting optimizer   at 135670 last
step: 0 gc: 0 total: 12648
racket: tr-timing: Optimizedat 135677 last
step: 7 gc: 0 total: 12655
racket: tr-timing: Finished, returning to Racketat 135677 last
step: 0 gc: 0 total: 12655


2. This takes the most time.

module-prefetch: ((submod typed-racket/private/type-contract predicates)
typed-racket/utils/utils typed-racket/utils/any-wrap
typed-racket/utils/struct-type-c typed-racket/utils/opaque-object
typed-racket/utils/evt-contract typed-racket/utils/sealing-contract
typed-racket/utils/promise-not-name-contract
typed-racket/utils/simple-result-arrow racket/sequence
racket/contract/parametric)


3. The optimizer does the most tasks

racket: optimizer: inlining #(flat-contract-predicate
# 870 0
29870 121 #false) size: 9 threshold: 96# in module

pass[1]: compiling /Users/wargrey/Gyoudmon/
zuglag.com/nefertimon/digivice/nefertimon/nefertimon.rkt



Anyway. Thank you, Asumu.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] [racket][typed] static-contracts/instantiate.rkt:64:2. car: contract violation.

2016-04-17 Thread WarGrey Gyoudmon Ju
On Sun, Apr 17, 2016 at 3:35 PM, Asumu Takikawa  wrote:

> If you can send me whatever code is necessary to reproduce the bug (even if
> it's not very minimal), I can try to fix it.
>

Thank you Asumu for caring about this bug.
But now I cannot reproduce it in the real world code either, just like that
it appeared unreasonably. Let me see if it would show up again.


And here is another question. Developing GUI Application involves typed
class system heavily, which makes the compiling time terribly long (if this
is the root cause). It always counts in minutes, this bad experience
sometimes makes me depressed, and sometimes kills time unnoticeably. So do
you have any suggestions?

I think provides a global switch to turn off the typechecking would be
great.

#lang typed/racket/no-check
#lang typed/racket/base/no-check

these two #langs only affects there own file (also, there is no
typed/racket/gui/no-check).
Do we already have that global switch?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] [racket][typed] static-contracts/instantiate.rkt:64:2. car: contract violation.

2016-04-09 Thread WarGrey Gyoudmon Ju
This bug happened to appear two days ago and never disappear (both in
version 6.4.0.13 and 6.5.0.1) in my codebase, however if I copy the minimal
relative code into a fresh file, it disappears. In the original one's REPL,
it disappears too.

(define-type Card%
  (Class #:implements Darc-Card%
 [change (-> (Instance Snip%) Void)]))

(define card% : Card%
  (class darc-card% ;;; this is a pasteboard%
(super-new)
(define/public (change snip)
  (void

(define card : (Instance Darc-Card%) (make-object darc-card%)) ;;; this is
okay.
(define card : (Instance Card%) (make-object card%))  ;;; this raises the
contract error.

It is also easy to bypass as long as I do not do instantiating in module
level (as a static member of a class).

So, is it safe to just ignore the non-paired value in instantiate.rkt?
Thanks.

-- 
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] drracket / postgresql error when opening connection for syntax

2016-04-06 Thread WarGrey Gyoudmon Ju
I met this problem before.
(system-type 'machine) uses the output of `uname`.

On Wed, Apr 6, 2016 at 5:47 PM, Tim Brown  wrote:

> Folks,
>
> I’m experimenting with creating functions from a PostgreSQL database.
> [Frankly, I’m still getting my head around what I _actually_ want to do
> here, but...]
>
> When I load the following into DrRacket:
>
> ;; -
> #lang racket/base
> (require (for-syntax db racket/base))
>
> (define-for-syntax pga
>   (postgresql-connect
>#:user "tim"
>#:password "souper-secret-passwor*"
>#:port 5432
>#:database "tims_db"
>#:server "localhost"))
> ;; -
>
> I get the following in my status line:
>
> subprocess: forbidden (execute) access to /bin/uname
>
> This is causing my background execution to fail (red dot); although
> foreground execution is happy.
>
> I cannot find uname in the source; or in my .racketrc or anywhere in
> ~/.racket/ .
>
> Anyone have any clues?
>
> Tim
>
> Versions:
>
> $ racket
> Welcome to Racket v6.4.
> > (version)
> "6.4"
>
> $ uname -a
> Linux tim-8 4.4.0-1-amd64 #1 SMP Debian 4.4.6-1 (2016-03-17) x86_64
> GNU/Linux
>
> --
> Tim Brown CEng MBCS 
> 
> City Computing Limited · www.cityc.co.uk
>   City House · Sutton Park Rd · Sutton · Surrey · SM1 2AE · GB
> T:+44 20 8770 2110 · F:+44 20 8770 2130
> 
> City Computing Limited registered in London No:1767817.
> Registered Office: City House, Sutton Park Road, Sutton, Surrey, SM1 2AE
> VAT No: GB 918 4680 96
>
> --
> 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] [racket] typed racket needs editor-snip%

2016-03-30 Thread WarGrey Gyoudmon Ju
I made a pull request here: https://github.com/racket/typed-racket/pull/328

but it fails, the error report shows that failures do not caused by my
changes, I think...

On Tue, Mar 29, 2016 at 7:27 PM, Sam Tobin-Hochstadt <sa...@cs.indiana.edu>
wrote:

> You can use `Editor-Snip%` by requiring it from `typed/racket/gui`.
>
> Sam
>
> On Tue, Mar 29, 2016 at 4:09 AM, WarGrey Gyoudmon Ju
> <juzhenli...@gmail.com> wrote:
> > Hello, I am currently building a desktop application (which is a
> component
> > of a production system for customer) in typed racket.
> >
> > I found that typed/private/gui-types.rkt does have the definition of
> > Editor-Snip% but does not provide it in typed/racket/base. I do not know
> > where is your prefer place to do this. Would you please make it
> available?
> >
> > Thanks.
> >
> >
> > BTW, Racket is also a great language to *design* GUI applications(in a
> > programmable approach). Before I get deep into this kind of tasks, I
> thought
> > that the GUI infrastructure is poor, say, lacking of lots of useful
> > controllers. Actually, lots of them can be built with editor<%> and
> > racket/snip in few lines of code since this facility has a great (basic)
> > abstraction.
> >
> > --
> > 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] [racket] typed racket needs editor-snip%

2016-03-29 Thread WarGrey Gyoudmon Ju
Oh, yes, it works. Thank you.

On Tue, Mar 29, 2016 at 7:27 PM, Sam Tobin-Hochstadt <sa...@cs.indiana.edu>
wrote:

> You can use `Editor-Snip%` by requiring it from `typed/racket/gui`.
>
> Sam
>
> On Tue, Mar 29, 2016 at 4:09 AM, WarGrey Gyoudmon Ju
> <juzhenli...@gmail.com> wrote:
> > Hello, I am currently building a desktop application (which is a
> component
> > of a production system for customer) in typed racket.
> >
> > I found that typed/private/gui-types.rkt does have the definition of
> > Editor-Snip% but does not provide it in typed/racket/base. I do not know
> > where is your prefer place to do this. Would you please make it
> available?
> >
> > Thanks.
> >
> >
> > BTW, Racket is also a great language to *design* GUI applications(in a
> > programmable approach). Before I get deep into this kind of tasks, I
> thought
> > that the GUI infrastructure is poor, say, lacking of lots of useful
> > controllers. Actually, lots of them can be built with editor<%> and
> > racket/snip in few lines of code since this facility has a great (basic)
> > abstraction.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] [racket] typed racket needs editor-snip%

2016-03-29 Thread WarGrey Gyoudmon Ju
Hello, I am currently building a desktop application (which is a component
of a production system for customer) in typed racket.

I found that typed/private/gui-types.rkt does have the definition of
Editor-Snip% but does not provide it in typed/racket/base. I do not know
where is your prefer place to do this. Would you please make it available?

Thanks.


BTW, Racket is also a great language to *design* GUI applications(in a
programmable approach). Before I get deep into this kind of tasks, I
thought that the GUI infrastructure is poor, say, lacking of lots of useful
controllers. Actually, lots of them can be built with editor<%> and
racket/snip in few lines of code since this facility has a great (basic)
abstraction.

-- 
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] IO in racket is painful

2016-03-22 Thread WarGrey Gyoudmon Ju
On Wed, Mar 23, 2016 at 8:26 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com>
wrote:

> In Racket, (read) and (write) know all the builtin datatypes
> <https://docs.racket-lang.org/reference/reader.html?q=readtable#%28part._parse-number%29>
>  which
> are already structured more than a stream of bytes (like in C).
> Thus, you don't need scanf to tell Racket what is the type of the next
> token.
>
> That *is* painful in a situation like coding challenges since the input
> format is language independent (however actually it's the C style).
> Of course this kind of situation also has its own fixed format, you can
> define your own read tables
> <https://docs.racket-lang.org/reference/readtables.html?q=readtable> :
> 1. the "," is special in Racket, you need to drop off them first;  
> (with-input-from-string
> "[04 foo 03.5]" read) gives you '(4 foo 3.5) directly.
> 2. Symbols are internal Strings, you need (symbol->string) to covent them
> into normal Strings (Yes, sometimes, I think if there are string-like or
> bytes-like APIs that work on symbols directly).
>
>
Sorry, please forget the Read Table, it makes things more complex here.

-- 
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] IO in racket is painful

2016-03-22 Thread WarGrey Gyoudmon Ju
In Racket, (read) and (write) know all the builtin datatypes

which
are already structured more than a stream of bytes (like in C).
Thus, you don't need scanf to tell Racket what is the type of the next
token.

That *is* painful in a situation like coding challenges since the input
format is language independent (however actually it's the C style).
Of course this kind of situation also has its own fixed format, you can
define your own read tables
 :
1. the "," is special in Racket, you need to drop off them first;
(with-input-from-string
"[04 foo 03.5]" read) gives you '(4 foo 3.5) directly.
2. Symbols are internal Strings, you need (symbol->string) to covent them
into normal Strings (Yes, sometimes, I think if there are string-like or
bytes-like APIs that work on symbols directly).


On Wed, Mar 23, 2016 at 4:33 AM, rom cgb  wrote:

> Hi,
>
> I recently started using Racket and i couldn't find a good alternative to
> C's scanf/printf in the racket standard library. When doing programming
> challenges, you often need to comply to a specific input/ouput thus having
> something like scanf for string to values and printf for values to string
> is comfy.
>
> For example, let's say a challenge where you simply have to output the
> input but you need to translate the strings input into values and then
> those values back to strings.
>
> The given input(and excepted ouput) is
>
>   3
>   [04, foo, 03.5]
>   [05, bar, 04.6]
>   [06, fun, 05.7]
>
> In C, you would simply do
>
>   #include 
>
>   int main(void)
>   {
>   int n;
>
>   // Read number of rows
>   scanf("%d\n", );
>
>   // Output number of rows
>   printf("%d\n", n);
>
>   // Process rows
>   for (unsigned int i; i < n; ++i)
>   {
>   int a;
>   char b[20];
>   float c;
>
>   // Read row
>   scanf("[%d, %[^,], %f]\n", , b, );
>
>   // Output row
>   printf("[%02d, %s, %04.1f]\n", a, b, c);
>   }
>   }
>
> Now, for a solution in Racket, You first have to read the first line and
> convert it into a number.
>
>   (define rows (string->number (read-line)))
>
> Then, for all rows, read and split the string. The best that i have found
> to do that is using regular expressions.
>
>   (define split-row (regexp-match #rx"\\[(.+), (.+), (.+)\\]" (read-line)))
>
> Then you have to manually convert the substrings into values
>
>   (define a (string->number (second split-row)))
>   (define b (third split-row))
>   (define c (string->number (fourth split-row)))
>
> Then you have to manually convert the values back into strings
>
>   (printf "[~a, ~a, ~a]\n"
>   (~a a #:width 2 #:align 'right #:pad-string "0")
>   b
>   (~r c #:min-width 4 #:precision 1 #:pad-string "0")))
>
> This is way more tedious than with the classical input/output format,
> especially when you are doing coding challenges.
>
> Final Racket solution:
>
>   #lang racket
>
>   (define rows (string->number (read-line)))
>
>   (for ([in-range rows])
> (define split-row (regexp-match #rx"\\[(.+), (.+), (.+)\\]"
> (read-line)))
>
> (define a (string->number (second split-row)))
> (define b (third split-row))
> (define c (string->number (fourth split-row)))
>
> (printf "[~a, ~a, ~a]\n"
> (~a a #:width 2 #:align 'right #:pad-string "0")
> b
> (~r c #:min-width 4 #:precision 1 #:pad-string "0")))
>
>
> Having something like (not necessary the same specifiers as with printf)
>
>   (string-scan "[%d, %s, %f]" "[45, foo, 10.9]") -> '(45 "foo" 10.9)
>
> and a proper output formatter would be comfy.
>
> Are racket devs against such a thing in the standard library ?
> How you guys are actually doing IO in racket ?
>
> --
> 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] Web server catch exceptions, print stack trace to error-logs, display simple page to user

2016-03-20 Thread WarGrey Gyoudmon Ju
I just use the log facility that operating system uses, say, rsyslog.
rsyslog is configured to forward all logs via UDP, and there is another
racket UDP server that displays these logs on the terminal or sends to
other dev-ops. (rsyslog can be run as a normal user, then you can setup
your own log management strategy.)


On Fri, Mar 18, 2016 at 8:37 AM, Marc Kaufmann 
wrote:

> Hm, it sounded like I needed sudo rights to run daemontools if I want to
> use it to start racket as sudo (I may be wrong). Either way, the admins
> told me no, so no it is. Either supervisord or daemontools are of course
> several steps up from my previous way of doing things (which may justify
> their reasons for not giving me said sudo rights in the first place...).
>
> On Thu, Mar 17, 2016 at 8:29 PM, John Clements 
> wrote:
>
>>
>> > On Mar 17, 2016, at 4:48 PM, Marc Kaufmann 
>> wrote:
>> >
>> > Yep, printing that out is indeed all I want. I hadn't thought about the
>> fact that 'print and 'display will show up in standard output.
>> >
>> > John, how do you use drrackt's log handlers, are you running the server
>> via Drracket or did you mean something different.
>>
>> Forgive me, of course I didn’t mean “DrRacket’s log handlers,” but rather
>> “racket’s log handlers”, specifically those created by `define-logger`. My
>> mistake.
>> >
>> > I can't use daemontools for reasons to do with permissions, but I will
>> have access to supervisord, which seems to be doing the same type of tasks.
>>
>> ??
>>
>> I claim you can run daemontools (specifically, svscan) without any
>> permissions at all. Regardless, AFAIK supervisord does in fact achieve
>> similar ends.
>>
>> John
>>
>> >
>> > On Thu, Mar 17, 2016 at 4:46 PM, John Clements <
>> cleme...@brinckerhoff.org> wrote:
>> >
>> > > On Mar 17, 2016, at 11:50 AM, Marc Kaufmann <
>> marc.kaufman...@gmail.com> wrote:
>> > >
>> > > Hi all,
>> > >
>> > > I do not want people to see "Contract violation: massive stack trace
>> documenting my brilliance as a programmer" every time they hit a bug on my
>> website.
>> > >
>> > > Currently I show them simply an error page and redirect the trace to
>> stderr (see code below). But this doesn't track time of the error, and so
>> on. Is there a simple way to do this (seems like it should be a common
>> problem), or at least how to easily get the time-stamp from
>> servlet-error-response without having to manually pipe everything to stderr?
>> >
>> > I think this problem is one of the ones that falls into the “Lisp
>> crack”: specifically, implementing your own solution is sufficiently easy
>> that building a general-purpose solution winds up being more trouble than
>> it’s worth, and never quite covers all of the various users’ requirements.
>> Of course, this leads to lack of standardization.
>> >
>> > For me, I use drracket’s log handlers, make sure that everything winds
>> up on stdout, and then use ‘multilog’ from ‘daemontools’ to take care of
>> timestamps, partitioning (if desired) and log rotation.
>> >
>> > 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.
>

-- 
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] Setup/teardown for unit testing

2016-03-08 Thread WarGrey Gyoudmon Ju
Hi, Brina.
This is my README of how I use RackUnit in my project.

http://gyoudmon.org/~wargrey:wisemon/readme_rkt.html#%28elem._%28chunk._~3ctestsuite~3a._building._the._baby._digimon~3e~3a1%29%29

(test-suite

 (format

 "make ++only ~a" babymon-name)
#:before (domake #:check? #true)
(for

 ([goal (in-list

 (list

 README.md babymon.rkt))])
  (test-pred

 (format

 "~a should exist" (notdir goal)) file-exists?

 goal))


In my practice, I follow the idea of Behavior Driven Development, so in
this example, the #:before routine runs `make` to build something,
then the (for) routine check its behavior, say, it should create two files,
hence, there is a `goal` in the (for) loop as the input argument of
testcases.

In my opinion, RackUnit is just too flexible since you have the entire
Racket with you. Sometimes, the so-called #:before and #:after are just the
way of thinking with which concepts inherit from the XUnit framework,
actually, you can always forget them literally and treat the body of
(test-suite) as a normal Racket module, and you are writing a program that
tests other programs. After all, RackUnit knows how to find the suites and
cases and do its work in the right way. Besides the #:after routine, the
Racket Plumber is the final guard that can also works as the teardown
routine in case that RackUnit happen to fail its work. (Because tests and
results are embedded in the documentation, I always write macros that can
help me make the docs looks elegant.)



 ::=

(register-handbook-finalizer
 (thunk

 (delete-directory/files

 baby-zone)))


On Wed, Mar 9, 2016 at 2:35 AM, Brian Adkins  wrote:

> Not exactly. I'm looking for a way to run a function before *each*, of
> possibly many, test-cases. The test-suite #:before only runs once before
> running all the test-cases.
>
> Although my gist: https://gist.github.com/lojic/db7016fb95b1c05e4ade only
> has a few test-cases, if there were many, the redundancy of specifying the
> context each time would be annoying.
>
> What I'd really like is something similar to Elixir though, so I think
> I'll code up that macro/function. It would be more functional to have each
> test-case accept a context parameter, so you'd define a setup function that
> returns a value that each test-case accepts as input.
>
> It might look something like:
>
> (test-suite
>   "my test suite"
>   #:setup (lambda () (open-bank))
>
>   (test-case "initial balance is 0" account
> (check-eq? (balance account) 0))
>
>   ...
>
> So, the lambda specified in #:setup returns an object, account, that is
> passed to each test-case.
>
> I'll need to think of a reasonable syntax for it, but the idea is that
> each test-case in a suite will have context created for it functionally.
>
>
> On Tuesday, March 8, 2016 at 1:17:53 PM UTC-5, Matthias Felleisen wrote:
> > Are you looking for something like this:
> >
> > #lang racket
> >
> > (require rackunit rackunit/text-ui)
> >
> > (define my-database #f)
> >
> > (define my-first-test-suite
> >   (test-suite
> >"An example suite"
> >#:before (lambda () (set! my-database '(a b c)) (displayln `(Before
> ,my-database)))
> >#:after  (lambda () (set! my-database #f)   (displayln `(Before
> ,my-database)))
> >(test-case
> > "An example test"
> > (check-eq? 1 1))
> >(test-suite "A nested test suite"
> >(test-case "Another test"
> >   (check-equal? 1 2)
> >
> >
> > Welcome to DrRacket, version 6.4.0.13--2016-03-04(-/f) [3m].
> > Language: racket.
> > > (run-tests my-first-test-suite)
> > (Before (a b c))
> > 
> > An example suite > A nested test suite > Another test
> > Another test
> > FAILURE
> > name:   check-equal?
> > location:   unsaved-editor:17:26
> 

Re: [racket-users] Typed Racket

2016-02-21 Thread WarGrey Gyoudmon Ju
On Sun, Feb 21, 2016 at 4:13 PM, Asumu Takikawa <as...@ccs.neu.edu> wrote:

> On 2016-02-21 13:23:40 +0800, WarGrey Gyoudmon Ju wrote:
> >(exn:break:hang-up) and (exn:break:terminate) are useful in server
> >application, if I (typed/require) them in the a common rkt and this
> file
> >is also (require)ed by scribble (which is untyped), then it will
> complains
> >that they are already required. So can you make these two structs
> >available in typed racket?
>
> I just pushed a commit for this:
>
>
> https://github.com/racket/typed-racket/commit/a90f6c46eb016ad1c40ffad0c212464f34e300f0
>
>
Thank you, Asumu.


> Cheers,
> Asumu
>

-- 
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] Typed Racket

2016-02-20 Thread WarGrey Gyoudmon Ju
I use typed racket in production too, and I also heavily use Scribble on
the same source codebase.

Here is my requirement that not so important:
(exn:break:hang-up) and (exn:break:terminate) are useful in server
application, if I (typed/require) them in the a common rkt and this file is
also (require)ed by scribble (which is untyped), then it will complains
that they are already required. So can you make these two structs available
in typed racket? Thanks.

On Sun, Feb 21, 2016 at 12:12 PM, Benjamin Greenman <
benjaminlgreen...@gmail.com> wrote:

> Hi Piyush,
>
> Is it viable to use typed racket for production use ?
>>
>
> At least 3 people are using Typed Racket in production:
> -
> https://groups.google.com/forum/#!searchin/racket-users/typed$20racket|sort:date/racket-users/rfM6koVbOS8/JHaHG03cCQAJ
> - https://www.youtube.com/watch?v=QoYJfA7cq2I
> - https://twitter.com/ID_AA_Carmack/status/695702976745381889
>
>
>
>> is it entirely different language ?
>>
>
> Nope. Typed Racket's main design goal is to support the features of
> untyped Racket. You should be able to convert a #lang racket program to a
> #lang typed/racket program only by adding type annotations.
>
> Disclaimer: the type system is very expressive, but doesn't do much type
> inference. So may need to write a lot of annotations, for example
>
> (map (lambda ([v : (U 'cats 'dogs Natural)]) ...) '(9 cats 8 dogs))
>
> (for/fold : (U #f Integer)
>
>   ([biggest : (U #f Integer) #f])
>
>   ([i (in-list '(1 2 3 4))])
>
>   (if biggest
>
> (max biggest i)
>
> i))
>
>
> But we're always trying to improve.
>
>
>
>> how much extra speed/performance we achieve compare to plain racket ?
>>
>
> You can expect modest runtime improvements if your whole program is
> written in Typed Racket. Probably 5-10%, but I've seen 30% for a program
> that made lots of vector accesses. Arithmetic can get much faster too.
> Clicking the optimization coach button in Dr. Racket will find places where
> the optimizer might be able to do more with the types.
>
> (Compile times will be slower, though)
>
>
> Does it support all open source libs ?
>>
>
> You can use any Racket library in Typed Racket if you give a
> `require/typed` annotation that matches your use-case:
>
> (require/typed
>
>   [serialize (Any -> Any)]
>
>   [deserialize (Any -> (HashTable Symbol (List Integer)))])
>
>
> One thing to keep in mind: these type annotations are checked at runtime,
> so each call to deserialize will be a little slower to make sure it really
> gives a hashtable with the right values inside. The slowdowns can add up in
> surprising ways, but we're working on that too.
>
>
> Hope you'll try Typed Racket. We're happy to answer questions here or on
> the #racket IRC channel.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Re: (eqv? Racket-land Wonderland) -> #t

2016-02-17 Thread WarGrey Gyoudmon Ju
On Sun, Feb 14, 2016 at 8:10 PM, Saša Janiška  wrote:

> Neil Van Dyke  writes:
>
> > Being non-mainstream for practitioners, Racket is most popular with
> > people who have the freedom to choose any tools they want, not forced
> > into a mainstream set of options. Most often this means individual
> > alpha techies, researchers, etc.
>
> That's true, but still wonder why not more hobbyist are using it.
>

AFAIK, when other developers(even users in this maillist) mention Racket,
they are talking about Scheme which is thought not designed for
practitioners. When they talk about the real world application of Racket,
they only know the Hacker News which is made in old scheme.

Racket has lots of great tools that you named above, however, hobbyists may
not buy it. Say, every developer does not like to write docs while hating
other developers who do not write docs. Perhaps the most important thing is
that the idea of "Embedding executable/testing code in the docs" is beyond
their practice (even beyond the Literate Programming).

I just made myself an opportunity to work as a full stack Racket developer
four months ago. This is also a good chance to show others that Racket is
powerful or at least not so bad even in their concerns (the roadmap of full
spectrum).

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] A template/example to use to build a workflow illustration/flowchart in slideshow

2016-01-16 Thread WarGrey Gyoudmon Ju
you can use (system) run graphviz, then load the resulting picture into
slideshow with (bitmap) of pict.

On Sat, Jan 16, 2016 at 8:22 AM, ckkashyap  wrote:

> Thanks Jordan ... I was aware of the tutorial source ... I was looking for
> something that let me draw a flowchart quickly - I used graphviz for it and
> it worked for me :)
>
> Regards,
> Kashyap
>
> On Friday, January 15, 2016 at 10:19:55 AM UTC-8, Jordan Johnson wrote:
> > Yes. The slideshow tutorial referenced near the top of
> >  http://docs.racket-lang.org/slideshow/index.html
> > ("Run Tutorial") incorporates a slideshow in which you can inspect the
> source.
> >
> >
> > Best,
> > Jordan
> >
> > On Jan 13, 2016, at 5:10 PM, C K Kashyap  wrote:
> >
> >
> >
> > Dear group,
> >
> >
> > I am trying to use racket for my presentation - essentially document the
> flow of code of a system I've been going through for a few days - I was
> wondering if there is a slideshow example that I could use to build on top
> of to illustrate a workflow.
> >
> >
> > Regards,
> > Kashyap
> >
> >
> >
> >
> > --
> >
> > 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...@googlegroups.com.
> >
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Racket performance tips

2016-01-16 Thread WarGrey Gyoudmon Ju
Yes.
What Bytes in Racket is what char * in C.
String treats the chars as a UTF-8 value.

On Sun, Jan 17, 2016 at 12:59 PM, Brian Adkins 
wrote:

> On Saturday, January 16, 2016 at 11:54:05 PM UTC-5, Brian Adkins wrote:
> > On Saturday, January 16, 2016 at 11:26:14 PM UTC-5, Neil Van Dyke wrote:
> > > Your code is very string-ops-heavy, and I would start looking at that.
> > > One thing you could do is look for opportunities to construct fewer
> > > intermediate strings, including across multiple procedure calls.  You
> > > could also look for operations that are expensive, and use
> > > less-expensive ones.  If your strings have no multibyte characters,
> it'd
> > > be easier to make it a lot faster with reused bytes I/O buffers and a
> > > tons less copying, but you could also try that with multibyte
> characters
> > > (it's harder and slower, though).
> > >
> > > If you get fancy with the optimization, you might end up with a DSL or
> > > mini-language for the formats and/or transformation, to simplify the
> > > source code while making its behavior more sophisticated.  But maybe
> you
> > > want to focus on a proof-of-concept for the optimizations first, before
> > > you go to the work of implementing the DSL.
> > >
> > > BTW, the below comment, from an aborted response to your previous
> email,
> > > doesn't seem to apply to your code, but I'll just note it for the
> record:
> > >
> > > >
> > > > Without tracing through the actual code being profiled (not
> > > > volunteering!), it's hard to say what the fix is.
> > > >
> > > > One little tip, from glancing at "collects/racket/string.rkt"... If
> > > > your code happens to be calling `string-trim` with a large number of
> > > > different `sep` arguments (different by `eq?`), it looks like it will
> > > > be especially slow.  Or if you're calling `string-trim` a huge number
> > > > of times with a nonzero number of non-`#f` `sep` arguments, and
> you're
> > > > GCing.  (The implementation assembles regular expressions for
> non-`#f`
> > > > `sep` arguments, and caches them in a weak hash with `eq?` test.)
> > >
> > > BTW, I wouldn't be surprised if `string-trim` could be made faster for
> > > the normal case of `sep` being `#f`, though the code doesn't look bad
> > > right now.  (The majority of code that people write is not very
> > > efficient, and `string-trim` looks better than the norm.) However, it
> > > was written in a generalized way, and I don't know if anyone sat down
> > > and hand-optimized for the `#f` case specifically. Or, it might have
> > > been written a long time ago, and the VM/compiler or strings have
> > > changed quite a bit since then, and so the code could benefit from
> > > re-hand-optimizing.  (I've done a bunch of that kind of optimizing as a
> > > consultant, and it can easily take a few hours for a single procedure,
> > > so tends to only happen as-needed.)
> > >
> > > Neil V.
> >
> > For this app, the data is actually straight ASCII upper case mainframe
> data :)
> >
> > Can you elaborate re: "reused bytes I/O buffers "  ?  One of the things
> I did in the C code was to reuse character arrays a lot and never malloc,
> but I'm less familiar with doing similar things in Racket.
> >
> > I'm not opposed to hand optimizing (the C program was basically one
> gigantic optimization), but to be fair, it seems the same optimizations
> would need to be done to the Ruby code for comparison.
> >
> > In other words, I have two related, but different goals:
> >
> > 1) I'd like to get to the point of being able to write expressive, "high
> level" code in Racket, in a similar manner as I've been accustomed to with
> Ruby, but with better performance than Ruby. Given Ruby typically trails
> the pack with respect to speed, that doesn't seem unreasonable.
> >
> > 2) I'd also like to get a better idea of practical optimizations that I
> can use with Racket when I need more speed, even if it lessens other
> aspects of the code such as readability, etc. I suppose the string-squeeze
> function in the Racket code is an example of that.
>
> So, maybe replace in-lines with in-bytes-lines on line 31 of
> https://gist.github.com/lojic/f306104846d516761952 and flow Byte Strings
> through the app instead of Strings given the source being ASCII chars ?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] Re: [racket] Sorry, but what's the correct way to use `#lang scribble/lp2`

2016-01-11 Thread WarGrey Gyoudmon Ju
Oh, yes, perhaps I did not understand Symbols well, especially in TEXT MODE.
I don't remember how did I find the solution.

Nonetheless, thank you all the same.

On Tue, Jan 12, 2016 at 2:42 AM, Ismael Figueroa <ifiguer...@gmail.com>
wrote:

> Maybe it is too late for this, but I run into the same issue just now...
>
> In my case I get the same error when using:
>
> @include-section["path.rkt"]
>
> but it works when using
>
> @include-section[(submod "path.rkt" doc)]
>
> probably because the scribble/lp2 is not providing the doc submodule
> expected by scribble itself...
>
> Cheers
>
>
>
> 2015-02-21 11:22 GMT-02:00 WarGrey Gyoudmon Ju <juzhenli...@gmail.com>:
>
>> Glad to see the literate programming technology updated.
>> I thought it might be a "Forgotten Feature" since the rest of scribble is
>> so powerful and I cannot find any code base use it.
>> Thank you.
>>
>> So... there still should be more examples to work with it.
>> What's the extra work (rather than simply replacing scribble/lp with
>> scribble/lp2) has to be done to make it able to be `include-section`ed?
>>
>> `scribble path.rkt`
>> `raco scribble path.rkt`
>> `(include-section (submod "path.rkt" doc))`
>> All of these complain:
>> path-only: contract violation
>>   expected: (or/c path-string? path-for-some-system?)
>>   given: #f
>>
>> and `(include-section "path.rkt")` complains:
>> handbook.scrbl:71:18: only-in: identifier `doc' not included in nested
>> require spec at: "path.rkt" in: (only-in "makefile.rkt" (doc doc))
>>
>>
>> 
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>>
>
>
> --
> Ismael
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] [racket] suggestions on scribble/example

2016-01-09 Thread WarGrey Gyoudmon Ju
1. Could you please treat the exn:fail:unsupported like a normal case as if
it is wrapped by (eval:error)?

http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._typed-racket%2Fbase-env%2Fbase-types..rkt%29._.Ext.Fl.Vector%29%29

this example is about ExtFlVector which is not supported in my openindiana
box.

2.
http://docs.racket-lang.org/reference/Reading.html?q=read-language#%28def._%28%28quote._~23~25kernel%29._read-language%29%29

this example is about (read-language), algol60 is not special here, however
user-developers have to install it.




These two do not make sense in everyday use, just be mentioned by raco pkg
install, however it affects the auto-update script.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] [racket] suggestions on scribble/example

2016-01-09 Thread WarGrey Gyoudmon Ju
Oh, I see the alternative solution for  #1.
https://github.com/racket/typed-racket/pull/288

Your discussion there is delightful.
Thanks.

On Sun, Jan 10, 2016 at 2:51 AM, Robby Findler <ro...@eecs.northwestern.edu>
wrote:

> Yes, right. This is why I suggested drdr.
>
> Robby
>
> On Sat, Jan 9, 2016 at 11:38 AM, Sam Tobin-Hochstadt
> <sa...@cs.indiana.edu> wrote:
> > We do run the core racket tests without exflonums on Travis; you can
> > see an example here:
> > https://travis-ci.org/racket/racket/jobs/101270780
> >
> > Unfortunately, building all of Racket + everything else takes more
> > time that various hosted CI systems allow. If there was a build of
> > Racket without extflonums, then the Typed Racket CI could test that,
> > but there are a lot of different configurations to test, and that
> > requires individual per-package effort.
> >
> > Sam
> >
> > On Sat, Jan 9, 2016 at 11:13 AM, Robby Findler
> > <ro...@eecs.northwestern.edu> wrote:
> >> Could this problem be helped if we run something like drdr, but in
> >> more configurations? (That doesn't seem particularly simple, tho.)
> >>
> >> Robby
> >>
> >>
> >> On Sat, Jan 9, 2016 at 10:07 AM, Matthew Flatt <mfl...@cs.utah.edu>
> wrote:
> >>> At Sat, 9 Jan 2016 08:34:45 -0700, Matthew Flatt wrote:
> >>>> At Sat, 9 Jan 2016 22:58:00 +0800, WarGrey Gyoudmon Ju wrote:
> >>>> > 1. Could you please treat the exn:fail:unsupported like a normal
> case as if
> >>>> > it is wrapped by (eval:error)?
> >>>> >
> >>>> >
> >>>>
> http://docs.racket-lang.org/ts-reference/type-ref.html#%28form._%28%28lib._type
> >>>> > d-racket%2Fbase-env%2Fbase-types..rkt%29._.Ext.Fl.Vector%29%29
> >>>> >
> >>>> > this example is about ExtFlVector which is not supported in my
> openindiana
> >>>> > box.
> >>>>
> >>>> Treating an `exn:fail:unsupported` error as if wrapped by `eval:error`
> >>>> sounds reasonable to me.
> >>>
> >>> On further reflection, that seems like a bad idea  --- repeating the
> >>> mistakes of `scribble/eval`.
> >>>
> >>> I think it's better in this case to adjust the documentation. I don't
> >>> have a good idea on how to prevent this kind of problem in the future,
> >>> though.
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >> --
> >> You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> >> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] [racket] Racket 6.3(.0.7) breaks old code

2015-12-25 Thread WarGrey Gyoudmon Ju
An additional feedback.
There was a ghost bug in my code, and it only appeared after compiling.

module-path-index-resolve: "self" index has no resolution
  module path index: #<module-path-index:()>
  context...:
   /opt/PLTracket/collects/syntax/private/id-table.rkt:77:2: do-ref

 
/opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/rep/interning.rkt:22:13:
*Name
   (submod /Users/wargrey/Gyoudmon/zuglag.com/sakuyamon/digitama/posix.rkt
typed/ffi #%type-decl): [running body]

 /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/env/env-req.rkt:8:4:
for-loop

 /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:82:0:
tc-module/full

 /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:24:4
   standard-module-name-resolver

I struggled so many days to try to find other reasons or workarounds,
however there was no luck any more.
Just a moment ago, I noticed an unused (require)s and commented that line,
then it works with leaving a miracle.

This is the best gift for me, and Merry Christmas to all of you.

On Wed, Dec 2, 2015 at 11:38 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> Thanks for the example!
>
> The problem is a bug in `namespace-mapped-symbols` (due to changes
> related to the new macro expander). I will push a repair later today.
>
> At Mon, 30 Nov 2015 20:16:44 +0800, WarGrey Gyoudmon Ju wrote:
> > Thank you, Matthew.
> >
> > The project itself is organized as a multi package, however there is no
> > need to install it.
> >
> > Debug/DigiGnome  ; this subpackage is the base one of the other two.
> > Debug/Kuzuhamon/; this one meets the second problem
> > Debug/sakuyamon/ ; this one meets the first problem
> > Debug/sakuyamon/digitama/dispatch.rkt ; it is the buggy source
> > Debug/Kuzuhamon/digivice/land-bang.rkt   ; it is the buggy source, the
> bug
> > only occurs after building
> > Debug/DigiGnome/makefile.rkt; it builds the entire
> > project with (compile-directory-zos) and info.rkt
> > Debug/DigiGnome/digitama/digicore.rkt  ; it is the entry module (but
> > not the application launcher) of all
> > Debug/DigiGnome/digitama/posix.rkt  ;
> > (module-prefab:cstruct/no-auto-update) is here.
> >
> > digitama means 'private', while digivice means 'bin'.
> > to build the project, just `cd` into the target directory DigiGnome,
> > sakuyamon, or Kuzuhamon, then run `../DigiGnome/makefile.rkt`.
> >
> > (module-prefab:cstruct/no-auto-update) defines a submodule which contains
> > another submodule in it. The purpose is defining prefab structs based on
> c
> > structs for both untyped and typed racket. Currently it is used in
> > sakuyamon/digitama/posix.rkt to get the system stats.
> >
> > dispatch.rkt always stops the building process (and `racket`),
> makefile.rkt
> > itself is all right with this minimal code base, actually it just fails
> > following the other failures. weird.
> >
> > So... if there is something wrong with the compiler (makefile.rkt itself
> is
> > also compiled)?
> > without compiling, digivice/land-bang.rkt can load the games (with
> > in Kuzuhamon/village/land-of-lisp) correctly.
> >
> >
> > On Mon, Nov 30, 2015 at 8:54 AM, Matthew Flatt <mfl...@cs.utah.edu>
> wrote:
> >
> > > My guess is that you're running into an incompatibility created by the
> > > new macro system. Something like lifting code out of an expanded
> > > `module` form and dropping it into a different one? A change related to
> > > submodule expansion? Or something related to the top-level namespace?
> > > It might be an unavoidable incompatibility, or it might be a bug.
> > >
> > > I'm unclear on what I'd need to do to replicate the problem, though. Is
> > > there some code of yours that's available and that I could try to run?
> > >
> > > At Mon, 30 Nov 2015 06:53:28 +0800, WarGrey Gyoudmon Ju wrote:
> > > > It is compiled by myself with no strange options.
> > > > Rebuilding the project (without DrRacket) fails due to two strange
> > > > behaviors.
> > > >
> > > > The first one is module-path-index-resolve: "self" index has no
> > > resolution.
> > > > It breaks lots of scripts, I cannot locate where it is exactly
> occurs.
> > > > 1. errortrace says  makefile.rkt:364:35: (namespace-mapped-symbols)
> > > >  this is my building facility written in untyped racket, the
> > > stack
> > > > point is parameterized with (variable-reference->namespace
> > > > (#%variable-referenc

[racket-users] [racket][scribble] UNSYNTAX and lp

2015-12-17 Thread WarGrey Gyoudmon Ju
I see docs says UNSYNTAX can be used to escape code to scribble lots of
times.
So what is the UNSYNTAX?

In lp chunks, are there any examples to demonstrate how to keep comments in
the resulting docs?



In my practice, tests are written in lp. If there is a way to keep the
original form of a number, this kinda test will become more readable:

[0x29b7f4aa : uint32 =>

 [0x29 0xb7 0xf4 0xaa]]

currently the 0x... symbols will be mapped to integers.


Perhaps these are not the features of the current lp implementation since
UNSYNTAX sure break the normal code from `racket`'s standpoint. Anyway am I
lucky enough if there already are some solutions?

Thanks. :p

-- 
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 there a way to return no value?

2015-12-11 Thread WarGrey Gyoudmon Ju
Oh, that's interesting.

> (void? (values))
Type Checker: expected single value, got multiple (or zero) values in:
(values)

On Fri, Dec 11, 2015 at 8:15 PM, Jay McCarthy 
wrote:

> Hi David,
>
> You can return nothing with (values). The function "values" returns
> any number of values... (values 1 2 3) returns 3 values, (values 1)
> returns 1 value, and (values) returns 0 values.
>
> Jay
>
> On Fri, Dec 11, 2015 at 1:16 AM, David K. Storrs 
> wrote:
> > Question: Is there a way to make a function return nothing -- not '() or
> #void, but actually nothing?
> >
> >
> > I'm playing around with HTML parsing as a learning exercise.  The
> current exercise is writing a look-down function which can be handed an
> HTML value produced by the html library and a function, run the function
> across the collect the results, and return them.  I would use this for
> things like "find every link in the following document" or "capitalize
> every use of the word 'kumquat'" or etc.
> >
> > I would like to have a way to say "this element isn't interesting, just
> ignore it" so that I don't get spurious return values in the results list.
> I can't see a way to do that...I can exclude the values afterwards, but
> that's not really what I was looking for, and opens the door to false
> negatives.
> >
> > Here's some simplified test code (removing all the HTML stuff for
> clarity) to show the point:
> >
> >
> > 
> > (define (foo-1 x) (if (eq? x "foo") #t '()))
> > (define (foo-2 x) (if (eq? x "foo") #t (values)))
> >
> > (map foo-1 '(a b "foo" "bar"))
> > (filter (lambda (x) (not (null? x))) (map foo-1 '(a b "foo" "bar")))
> > (map foo-2 '(a b "foo" "bar"))
> >
> > [dstorrs@localhost:~/personal/study/scheme/spider:]$ racket
> test.rkt
> > racket test.rkt
> > '(() () #t ())
> > '(#t)
> > result arity mismatch;
> >  expected number of values not received
> >   expected: 1
> >   received: 0
> >   values...:
> >   context...:
> >/Users/dstorrs/personal/study/scheme/spider/test.rkt: [running body]
> > 
> >
> > Instead of a 'result arity' crash, I would have liked to get '(#t) back,
> same a if I'd generated the list and then filtered it.
> >
> > Is there a way to do this?
> >
> >
> > For the record, here's the actual look-down function:
> >
> > (require (prefix-in h: html)
> >  (prefix-in x: xml))
> >
> > (define (look-down el action)
> >   (match el
> >  [(struct h:html-full (attributes content))
> >   (apply append (map action content))]
> >
> >  [(struct h:html-element (attributes))
> >   (action el)]
> >
> >  [ _ '()]))
> >
> > --
> > 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.


Re: [racket-users] Re: reducing pauses with incremental GC

2015-12-02 Thread WarGrey Gyoudmon Ju
I think, always.
Because they like games too.

On Thu, Dec 3, 2015 at 2:35 AM, Jack Firth  wrote:

> Absolutely fantastic! I wonder how often language designers implement
> features useful to game developers because of their children.
>
> --
> 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] [racket] Racket 6.3(.0.7) breaks old code

2015-11-30 Thread WarGrey Gyoudmon Ju
Thank you, Matthew.

The project itself is organized as a multi package, however there is no
need to install it.

Debug/DigiGnome  ; this subpackage is the base one of the other two.
Debug/Kuzuhamon/; this one meets the second problem
Debug/sakuyamon/ ; this one meets the first problem
Debug/sakuyamon/digitama/dispatch.rkt ; it is the buggy source
Debug/Kuzuhamon/digivice/land-bang.rkt   ; it is the buggy source, the bug
only occurs after building
Debug/DigiGnome/makefile.rkt; it builds the entire
project with (compile-directory-zos) and info.rkt
Debug/DigiGnome/digitama/digicore.rkt  ; it is the entry module (but
not the application launcher) of all
Debug/DigiGnome/digitama/posix.rkt  ;
(module-prefab:cstruct/no-auto-update) is here.

digitama means 'private', while digivice means 'bin'.
to build the project, just `cd` into the target directory DigiGnome,
sakuyamon, or Kuzuhamon, then run `../DigiGnome/makefile.rkt`.

(module-prefab:cstruct/no-auto-update) defines a submodule which contains
another submodule in it. The purpose is defining prefab structs based on c
structs for both untyped and typed racket. Currently it is used in
sakuyamon/digitama/posix.rkt to get the system stats.

dispatch.rkt always stops the building process (and `racket`), makefile.rkt
itself is all right with this minimal code base, actually it just fails
following the other failures. weird.

So... if there is something wrong with the compiler (makefile.rkt itself is
also compiled)?
without compiling, digivice/land-bang.rkt can load the games (with
in Kuzuhamon/village/land-of-lisp) correctly.


On Mon, Nov 30, 2015 at 8:54 AM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> My guess is that you're running into an incompatibility created by the
> new macro system. Something like lifting code out of an expanded
> `module` form and dropping it into a different one? A change related to
> submodule expansion? Or something related to the top-level namespace?
> It might be an unavoidable incompatibility, or it might be a bug.
>
> I'm unclear on what I'd need to do to replicate the problem, though. Is
> there some code of yours that's available and that I could try to run?
>
> At Mon, 30 Nov 2015 06:53:28 +0800, WarGrey Gyoudmon Ju wrote:
> > It is compiled by myself with no strange options.
> > Rebuilding the project (without DrRacket) fails due to two strange
> > behaviors.
> >
> > The first one is module-path-index-resolve: "self" index has no
> resolution.
> > It breaks lots of scripts, I cannot locate where it is exactly occurs.
> > 1. errortrace says  makefile.rkt:364:35: (namespace-mapped-symbols)
> >  this is my building facility written in untyped racket, the
> stack
> > point is parameterized with (variable-reference->namespace
> > (#%variable-reference)).
> >
> > 2. errortrace says nothing, while `racket` puts
> > module-path-index-resolve: "self" index has no resolution
> >   module path index: #<module-path-index:()>
> >   context...:
> >/opt/PLTracket/collects/syntax/private/id-table.rkt:77:2: do-ref
> >
> >
> >
> /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/rep/interning.rkt:22:13
> > :
> > *Opaque
> >(submod .../digitama/posix.rkt typed/ffi #%type-decl): [running body]
> >
> >
> /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/env/env-req.rkt:8:4:
> > for-loop
> >
> >
> /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:82:0:
> > tc-module/full
> >
> >
> /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:24:4
> >standard-module-name-resolver
> >
> >
> /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:82:0:
> > tc-module/full
> >
> >
> /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:24:4
> >standard-module-name-resolver
> >
> > this is a normal module, only posix.rkt is written by me,
> > but... `racket posix.rkt` is okay, in which case, ffi bindings are
> written
> > in the top level module,   typed/ffi is its submodule, `racket` run the
> > tests based on the typed one. DrRacket complains
> > (current-load-relative-directory)
> > is false.
> >
> >
> >
> > The second one is compiled/expanded code out of context; cannot find
> > exports to restore imported renamings for module: ...
> > It seems that (dynamic-require) does not work with the correct
> > (current-directory) or (current-load-relative-directory).
> >
> > Thanks.
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> 

[racket-users] [racket] Racket 6.3(.0.7) breaks old code

2015-11-29 Thread WarGrey Gyoudmon Ju
It is compiled by myself with no strange options.
Rebuilding the project (without DrRacket) fails due to two strange
behaviors.

The first one is module-path-index-resolve: "self" index has no resolution.
It breaks lots of scripts, I cannot locate where it is exactly occurs.
1. errortrace says  makefile.rkt:364:35: (namespace-mapped-symbols)
 this is my building facility written in untyped racket, the stack
point is parameterized with (variable-reference->namespace
(#%variable-reference)).

2. errortrace says nothing, while `racket` puts
module-path-index-resolve: "self" index has no resolution
  module path index: #
  context...:
   /opt/PLTracket/collects/syntax/private/id-table.rkt:77:2: do-ref

 
/opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/rep/interning.rkt:22:13:
*Opaque
   (submod .../digitama/posix.rkt typed/ffi #%type-decl): [running body]

 /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/env/env-req.rkt:8:4:
for-loop

 /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:82:0:
tc-module/full

 /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:24:4
   standard-module-name-resolver

 /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/tc-setup.rkt:82:0:
tc-module/full

 /opt/PLTracket/share/pkgs/typed-racket-lib/typed-racket/typed-racket.rkt:24:4
   standard-module-name-resolver

this is a normal module, only posix.rkt is written by me,
but... `racket posix.rkt` is okay, in which case, ffi bindings are written
in the top level module,   typed/ffi is its submodule, `racket` run the
tests based on the typed one. DrRacket complains
(current-load-relative-directory)
is false.



The second one is compiled/expanded code out of context; cannot find
exports to restore imported renamings for module: ...
It seems that (dynamic-require) does not work with the correct
(current-directory) or (current-load-relative-directory).

Thanks.

-- 
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] Typed Racket and struct

2015-11-19 Thread WarGrey Gyoudmon Ju
On Fri, Nov 20, 2015 at 3:27 AM, Antonio Menezes Leitao <
antonio.menezes.lei...@ist.utl.pt> wrote:

> Hi,
>
> On Thu, Nov 19, 2015 at 11:36 AM, WarGrey Gyoudmon Ju <
> juzhenli...@gmail.com> wrote:
>
>> 1. define structs in untyped racket;
>> 2. (require/typed/provide) it with #:constructor-name option.
>>
>>
> Thanks for the suggestion.
>
> Meanwhile, I thought about a different approach. Here is one example:
>
> (module test typed/racket
>   (struct foo
> ([a : Real]
>  [b : Integer]))
>   (provide (except-out (struct-out foo) foo)
>(rename-out [foo new-foo])))
>
> (require 'test)
>
> (define f (new-foo 1.0 2))
>
> (foo-a f)
>
> (foo-b f)
>
> Can you (or someone else) comment on the advantages of these two
> approaches?
>

Generally speaking, Racket Struct is not only a compact data collection
(like a vector with fields accessors, benefits both compiler and human
readers), Struct itself also has their own properties and methods to define
generic interfaces which is widely known in Class-based System (ignoring
that Racket Class-based System is also implemented in terms of Struct, they
are different things but have same effects).

Currently, Typed Racket only treats Struct as the compact data collection,
therefore, if you want to take full advantages of Struct, defining it in
untyped module than requiring it in typed module is the only choice, but
not vice versa.

I never tried your approach in practice, and you have already known the
side effects. Nonetheless, if you don't like the untyped way. How about
just defining one more function to make its instance? In this way, you also
have a more flexible guard procedure (see #:guard option). Besides I just
cannot understand the design of #:auto and #:auto-value options, it's so
weird that almost makes nonsense.


>
> Finally, can we define syntax to wrap both the module and the require? Is
> it possible for a macro to expand into such combination of forms? My quick
> experiments didn't produce the results I was expecting.
>

I found it impossible too.


>
> Best,
> António.
>

-- 
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] Typed Racket and struct

2015-11-19 Thread WarGrey Gyoudmon Ju
1. define structs in untyped racket;
2. (require/typed/provide) it with #:constructor-name option.

On Thu, Nov 19, 2015 at 5:11 PM, Antonio Menezes Leitao <
antonio.menezes.lei...@ist.utl.pt> wrote:

> Hi,
>
> I've been using Typed Racket in the last few months and it has been an
> interesting experience.
>
> However, there are a few helpful features of "normal" Racket that are not
> yet available in Typed Racket.
>
> One of them is the ability to use #:constructor-name in struct type
> definitions.
>
> I used rename-out as a replacement but it is not the same thing and it has
> other annoying effects.
>
> So, my questions are:
>
> 1. Are there any plans to support #:constructor-name in Typed Racket?
>
> 2. Which techniques do you recommend to circumvent that lack
> of #:constructor-name ?
>
> Best regards,
> António.
>
> --
> 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] Configuration Files

2015-11-19 Thread WarGrey Gyoudmon Ju
Yes, I like the idea of #lang info(#lang setup/infotab) which is highly
constrained, and it is an out-of-box solution.
It's better to have a (get-info/file filename.rkt) as an alternative to
(get-info/full infodir-path).


On Thu, Nov 19, 2015 at 7:32 AM, Neil Van Dyke  wrote:

> I generally second the idea of doing a configuration file format like
> "info.rkt" (but not using that particular filename, unless your program is
> tools for Racket development projects).
>
> An advantage of this format is that you then have a few different options
> for how to use the file.  Specifically, if the file format looks like
> Racket code, you can use it via `read`/`read-syntax` (while setting
> parameters for safety), via `dynamic-require`, or via `require`.
>
> And you can change your mind how to use the format later, without
> requiring end users to change the documented file format they use.
>
> If you eventually go to `dynamic-require` or `require`, then you can add
> more Racket language features to the "configuration file", and then it's an
> extensibility language, or your program is a domain-specific framework.
> This is also a good way to ease people into extension, and into using
> Racket.
>
> Neil V.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] Configuration Files

2015-11-18 Thread WarGrey Gyoudmon Ju
info.rkt, that's its name, you can search it in docs for details.

On Thu, Nov 19, 2015 at 6:39 AM, Sam Tobin-Hochstadt 
wrote:

> I usually use a file that I `read` and `write` with racket data,
> probably a hash table.
>
> Sam
>
> On Wed, Nov 18, 2015 at 5:19 PM, Christopher Walborn 
> wrote:
> > I'm looking for a way to read configuration files. The configuration
> file format can be anything provided it's easily human readable/writable. I
> found the ApacheConf solution on RosettaCode and may use that, but am
> wondering if there is a conf format that's more commonly used for Racket
> projects.
> >
> > There's no serious need for portability, longevity or anything else. I'm
> just using it to provide some settings and paths to local utilities in
> shell scripts which are little more than wrappers around other utilities.
> >
> > Thanks,
> > Christopher
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to racket-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] [racket][FFI] memory management when making io ports in C

2015-09-24 Thread WarGrey Gyoudmon Ju
  
-  lwp# 7 / thread# 7  
-  lwp# 8 / thread# 8  

Three SSH clients are running in three places separately, all APIs are
FFIed without '#:in-orignal-place'. The GC itself crushed in thread #1. I
do not make subprocess explicitly and the main place is running with
ncurses bindings.

On Fri, Sep 18, 2015 at 3:00 AM, WarGrey Gyoudmon Ju <juzhenli...@gmail.com>
wrote:

> Okay, thank you Matthew.
>
> On Thu, Sep 17, 2015 at 10:17 PM, Matthew Flatt <mfl...@cs.utah.edu>
> wrote:
>
>> At Thu, 17 Sep 2015 21:29:35 +0800, WarGrey Gyoudmon Ju wrote:
>> > On Wed, Sep 16, 2015 at 7:36 PM, Matthew Flatt <mfl...@cs.utah.edu>
>> wrote:
>> >
>> > > But, also, to use either of those, you need to use "xform" to
>> adjustthe
>> > > C code for GC, or you need to adjust the C code to cooperate
>> explicitly
>> > > with the GC using MZ_GC_DECL_REG(), etc. Are you using "xform"
>> already?
>> > >
>> > >
>> > > More generally, this code looks like something that is more easily
>> > > handled by Racket and `ffi/unsafe`, instead of writing new C code. You
>> > > still have to be aware of GC issues, but not to the same degree.
>> >
>> >
>> >  No, I have not use "xform" yet. This module does work with FFI. It is a
>> > chance to learn Racket more deeply.
>> >
>> > So is explicitly adjust the C code with MZ_GC_DECL_REG() also the right
>> way
>> > to work with realloc(3)?
>>
>> Sorry that I forgot to answer the part about replacing libssh2's
>> allocation functions. I don't think that's going to work at all, since
>> libssh2 doesn't cooperate with the garbage collector.
>>
>> (If it were just a matter of having a scheme_realloc(), you could
>> implement it with scheme_malloc() and memcpy().)
>>
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] [racket][FFI] memory management when making io ports in C

2015-09-17 Thread WarGrey Gyoudmon Ju
Okay, thank you Matthew.

On Thu, Sep 17, 2015 at 10:17 PM, Matthew Flatt <mfl...@cs.utah.edu> wrote:

> At Thu, 17 Sep 2015 21:29:35 +0800, WarGrey Gyoudmon Ju wrote:
> > On Wed, Sep 16, 2015 at 7:36 PM, Matthew Flatt <mfl...@cs.utah.edu>
> wrote:
> >
> > > But, also, to use either of those, you need to use "xform" to adjustthe
> > > C code for GC, or you need to adjust the C code to cooperate explicitly
> > > with the GC using MZ_GC_DECL_REG(), etc. Are you using "xform" already?
> > >
> > >
> > > More generally, this code looks like something that is more easily
> > > handled by Racket and `ffi/unsafe`, instead of writing new C code. You
> > > still have to be aware of GC issues, but not to the same degree.
> >
> >
> >  No, I have not use "xform" yet. This module does work with FFI. It is a
> > chance to learn Racket more deeply.
> >
> > So is explicitly adjust the C code with MZ_GC_DECL_REG() also the right
> way
> > to work with realloc(3)?
>
> Sorry that I forgot to answer the part about replacing libssh2's
> allocation functions. I don't think that's going to work at all, since
> libssh2 doesn't cooperate with the garbage collector.
>
> (If it were just a matter of having a scheme_realloc(), you could
> implement it with scheme_malloc() and memcpy().)
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[racket-users] [racket][FFI] memory management when making io ports in C

2015-09-16 Thread WarGrey Gyoudmon Ju
Hello.

foxpipe.c is a wrapper of libssh2 APIs that suitable to work with (sync)
and custodian. Everything is okay except that the sigfault annoys me a lot.

typedef struct foxpipe_session {

LIBSSH2_SESSION *sshclient;

Scheme_Input_Port *dev_tcpin;

Scheme_Output_Port *dev_tcpout;

intptr_t sockfd;

} foxpipe_session_t;


typedef struct foxpipe_channel {

foxpipe_session_t *session;

LIBSSH2_CHANNEL *channel;

char read_buffer[LIBSSH2_PACKET_MAXCOMP];

size_t read_offset;

size_t read_total;

} foxpipe_channel_t;

foxpipe_session_t *foxpipe_construct(Scheme_Object *tcp_connect,
Scheme_Object *sshd_host, Scheme_Object *sshd_port) {

foxpipe_session_t *session;

Scheme_Object *argv[2];


session = NULL;

argv[0] = sshd_host;

argv[1] = sshd_port;

scheme_apply_multi(tcp_connect, 2, argv);


if (scheme_current_thread->ku.multiple.count == 2) {

LIBSSH2_SESSION *sshclient;

Scheme_Input_Port *dev_tcpin;

Scheme_Output_Port *dev_tcpout;


dev_tcpin = (Scheme_Input_Port
*)scheme_current_thread->ku.multiple.array[0];

dev_tcpout = (Scheme_Output_Port
*)scheme_current_thread->ku.multiple.array[1];

sshclient = libssh2_session_init();


if (sshclient != NULL) {

session = (foxpipe_session_t *)malloc(sizeof
(foxpipe_session_t));

session->sshclient = sshclient;

session->dev_tcpin = dev_tcpin;

session->dev_tcpout = dev_tcpout;

scheme_get_port_socket((Scheme_Object *)dev_tcpin,
>sockfd);

} else {

scheme_close_input_port((Scheme_Object *)dev_tcpin);

scheme_close_output_port((Scheme_Object *)dev_tcpout);

}

}


return session;

}

static intptr_t channel_read_ready(Scheme_Input_Port *p) {

foxpipe_channel_t *foxpipe;

LIBSSH2_SESSION *session;

intptr_t read;


/**

 * Returns 1 when a non-blocking (read-bytes) will return bytes or an
EOF.

 */


foxpipe = (foxpipe_channel_t *)(p->port_data);

session = foxpipe->session->sshclient;


/**

 * This implementation is correct since all channels in a session are

 * sharing the same socket discriptor. When Racket is woken up by event,

 * It would likely check like this to see if the coming data belongs

 * to this channel.

 */


if (foxpipe->read_offset < foxpipe->read_total) {

read = foxpipe->read_total - foxpipe->read_offset;

} else {

scheme_fd_to_semaphore(foxpipe->session->sockfd, MZFD_CREATE_READ, 1
);

read = channel_fill_buffer(foxpipe);

}


return (read == LIBSSH2_ERROR_EAGAIN) ? 0 : 1;

}

intptr_t foxpipe_collapse(foxpipe_session_t *session, intptr_t reason_code,
const char *description) {

char libssh2_longest_reason[257];

size_t msize;

char *reason;



msize = sizeof(libssh2_longest_reason) / sizeof(char) - 1;

reason = description;

if (strlen(description) > msize) {

strncpy(libssh2_longest_reason, description, msize);

libssh2_longest_reason[msize] = '\0';

reason = libssh2_longest_reason;

}


/* TODO: Errors should be handled */


libssh2_session_disconnect_ex(session->sshclient, reason_code, reason,
"");

libssh2_session_free(session->sshclient);


scheme_close_input_port((Scheme_Object *)session->dev_tcpin);

scheme_close_output_port((Scheme_Object *)session->dev_tcpout);


free(session);


return 0;

}

--- called from signal handler with signal 11 (SIGSEGV) ---
 0282  ()
 fd7fe1248e2a libssh2_session_disconnect_ex () + ea
 fd7fea1f273e foxpipe_collapse () + 5e
 006f949a ffi_call_unix64 () + 4c

The above stack is the shape of almost all failures if I use
scheme_malloc() as the allocator. [More earlier, the failure may
occasionally occur at scheme_fd_to_semaphore running minutes or hours later
if scheme_malloc_atomic() is used]



Now I allocate memory for foxpipe_session_t and foxpipe_channel_t with the
syscall malloc(3),  so that Scheme_Input_Port and Scheme_Output_Port are
weakly held by the custodian.  Can I manage them manually?

Libssh2 APIs do allow developers using non-default allocators. Here is
another problem, Racket does not have something like scheme_realloc() which
maybe used in libssh2's transport layer. So is it a good idea to leave
scheme_malloc()ed objects to syscall realloc(3)? If so, and if required, I
have to pick up these pointers in my own free()?

I do not know exactly how is GC working. So maybe there are better
solutions. The basic idea is, 1.) the socket managed by libssh2 session is
useless for application, so it should not be available in Racket side. 2).
libssh2 channels are right ports for application to work with.

Another question, what is the order does custodian shutdown objects? Say,
if the original tcp 

Re: [racket-users] Using the draw and plot packages with other languages

2015-08-17 Thread WarGrey Gyoudmon Ju
On Sun, Aug 16, 2015 at 6:40 AM, Marduk Bolaños mardu...@gmail.com wrote:

 Coming back to my original question. What is your advice for using
 Racket's draw and plot in other programs?


Hi, Marduk.
There was a discussion that is close to your purpose.
http://lists.racket-lang.org/users/archive//2014-January/061247.html

But I think the easiest way is communicating through TCP socket.
You can launch a Racket tcp server application waiting for data sent by
your working languages and only do visualizing with it.

-- 
You received this message because you are subscribed to the Google Groups 
Racket Users group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [racket-users] What limits would you put on racket?

2015-07-23 Thread WarGrey Gyoudmon Ju
First of all, the first field I am interested in Computer Science can
reasonably marked as Programming Language itself.

Before I chose Racket, I used C and Java/ActionScript at work.
now Racket is the major one (among all languages not only lisp dialects) in
my life.
Many people choose Clojure for the season of taking advantages of Java
Platform.
I do not judge their choices, but for me, I prefer working with c shared
libraries.
Actually this is the common sense for Racketers who are working on real
life applications.
and this is also the most part that less productivity.

To be honest and to tell the truth, if Racket can be marked as a full stack
language,
lots of the facilities are just at the beginning stage, the so called out
of box with just basic equipments.
But you might have to implement you own frameworks when you want to build a
more complex system
(GUI, Web, Testing, Visualizing and so on),
the good news is that the community is very kind and always ready to help
you in a professional way.

To my poor knowledge of functional language communities.
Lots of people are drinking in exploring the potential abilities of the
languages,
and as simple but too powerful as lisp families are,
you can always find lots of solutions to solve one problem (just like
mainstream languages).
For me, this is the most thing that makes me headache,
I don't like choosing, especially to choose among lots of buggy
implementations.
That might be the curse of lisp families as well as haskell.
But Racket makes me feel comfortable, you know I do not even use the old
package system.

On Fri, Jul 24, 2015 at 5:11 AM, Sayth Renshaw flebber.c...@gmail.com
wrote:

 I received a direct reply from Doug.
 If you're strictly comparing Racket to other Lisp dialects, I would say
 there is never any reason to go to a different Lisp dialect. The main
 exception would be if there is some specific, existing capability in a
 different language that you require. But, that is not a dialect issue.

 I regularly use Racket for complex analysis tasks. The mathematic and
 plotting capabilities available are superior  (in my opinion) to other
 dialects.

 Your mileage may vary.

 Doug Williams


 Along those lines though but not necessarily limited to lisp dialects,
 where would racket become less productive. That is you would switch to
 another language to complete?

 Sayth

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


  1   2   >