[racket] What are some good practices of reading racket source code

2013-02-02 Thread WarGrey Gyoudmon Ju
Hello, dear all.

I am new to reading source code.
I want to read the Racket source code while working with C and Racket (and
lots of other languages).
Can you give me some good practices for avoiding potential pitfalls.
Thanks.

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] What are some good practices of reading racket source code

2013-02-02 Thread WarGrey Gyoudmon Ju
Thank you, Danny Yoo.
But as a C programmer, I was thinking more low-level as well such as
how does racket virtual machine manage its memory,
what is the implementation detail about its built-in data types,
and of course, I am interested in its mechanism and strategies based on
these facilities.

On Sun, Feb 3, 2013 at 5:33 AM, Grant Rettke  wrote:

> Thanks. I was thinking more about, how Racket itself works, where a
> newbie might start looking at the code.
>
> On Sat, Feb 2, 2013 at 3:30 PM, Danny Yoo  wrote:
> > On Sat, Feb 2, 2013 at 1:04 PM, Grant Rettke  wrote:
> >> In that same vein, what are good entry points for learning about how
> >> racket works? I think, learning how the #lang line itself works might
> >> be one of them?
> >
> > The Guide has an introduction to how #lang works:
> >
> > http://docs.racket-lang.org/guide/languages.html
> >
> > That may be a good place to start.
> >
> >
> > If you're looking for example-driven approaches, perhaps:
> >
> > http://hashcollision.org/brainfudge/
> >
> > may be applicable?  I also wrote up a quick-and-dirty example of
> > writing a #lang for a simple DSL for ascii diagrams for 'ragg':
> >
> >
> http://hashcollision.org/ragg/#(part._.Example__a_small_.D.S.L_for_.A.S.C.I.I_diagrams)
> >
> >
> >
> > For a more substantial example, perhaps Jens's minipascal project?
> >
> > https://pkg.racket-lang.org/info/minipascal
>
>
>
> --
> Grant Rettke | ACM, AMA, COG, IEEE
> gret...@acm.org | http://www.wisdomandwonder.com/
> Wisdom begins in wonder.
> ((λ (x) (x x)) (λ (x) (x x)))
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] What are some good practices of reading racket source code

2013-02-02 Thread WarGrey Gyoudmon Ju
More,
Are the comments descriptive enough to understand the source code,
or any other resources need to dig.

Thanks.

On Sun, Feb 3, 2013 at 1:11 PM, WarGrey Gyoudmon Ju
wrote:

> Thank you, Danny Yoo.
> But as a C programmer, I was thinking more low-level as well such as
> how does racket virtual machine manage its memory,
> what is the implementation detail about its built-in data types,
> and of course, I am interested in its mechanism and strategies based on
> these facilities.
>
> On Sun, Feb 3, 2013 at 5:33 AM, Grant Rettke  wrote:
>
>> Thanks. I was thinking more about, how Racket itself works, where a
>> newbie might start looking at the code.
>>
>> On Sat, Feb 2, 2013 at 3:30 PM, Danny Yoo  wrote:
>> > On Sat, Feb 2, 2013 at 1:04 PM, Grant Rettke  wrote:
>> >> In that same vein, what are good entry points for learning about how
>> >> racket works? I think, learning how the #lang line itself works might
>> >> be one of them?
>> >
>> > The Guide has an introduction to how #lang works:
>> >
>> > http://docs.racket-lang.org/guide/languages.html
>> >
>> > That may be a good place to start.
>> >
>> >
>> > If you're looking for example-driven approaches, perhaps:
>> >
>> > http://hashcollision.org/brainfudge/
>> >
>> > may be applicable?  I also wrote up a quick-and-dirty example of
>> > writing a #lang for a simple DSL for ascii diagrams for 'ragg':
>> >
>> >
>> http://hashcollision.org/ragg/#(part._.Example__a_small_.D.S.L_for_.A.S.C.I.I_diagrams)
>> >
>> >
>> >
>> > For a more substantial example, perhaps Jens's minipascal project?
>> >
>> > https://pkg.racket-lang.org/info/minipascal
>>
>>
>>
>> --
>> Grant Rettke | ACM, AMA, COG, IEEE
>> gret...@acm.org | http://www.wisdomandwonder.com/
>> Wisdom begins in wonder.
>> ((λ (x) (x x)) (λ (x) (x x)))
>>
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Realm of Racket

2013-06-18 Thread WarGrey Gyoudmon Ju
I've ordered the book with free ebook.
May I ask if the book is written in Scribble?


On Tue, Jun 18, 2013 at 11:17 PM, Matthias Felleisen
wrote:

>
>
> Dear list members,
>
> Realm of Racket is finally out.  For the first 72 hours, NoStarch.com
> offers a 40% off coupon  plus a free
> e-book version if you buy the book from their website. Otherwise the book
> is distributed through O'Reilly
> and is available at the usual places wherever O'Reilly sells its wares.
>
> ROAR is a book designed and authored by freshmen students from
> Northeastern, edited by myself and
> David Van Horn. It is intended for novices with some basic exposure to
> programming, not necessarily
> in Racket or Lisp-related languages. Following Conrad Barski's Land of
> Lisp, ROAR mixes instructions
> on programming with the creation of interactive games;, all of it
> illustrated with drawings and short cartoon
> stories. While LOL uses text-based gaming, ROAR is based on the HtDP 2e
> libraries, used inside of #lang
> racket modules. NoStarch.com's web site includes a sample chapter, "Hungry
> Henry", which showcases
> the creation of distributed GUI games.
>
> At Northeastern, we intend to use ROAR as the recommended bridge between
> HtDP/2e -- which does not
> use Racket but teaching languages -- and real Racket programming. I will
> also borrow exercises from ROAR
> to run my freshman course on program design.
>
> Congratulations to Mimi, Spencer, Rose, Eric, Scott, Ryan, Forrest, and
> Nicole for sticking through a
> two-year production process.
>
> Enjoy -- Matthias
>
> p.s. I am told you're welcome to re-distribute the coupon message below as
> widely as you wish.
>
>
>
>
>
>
> Begin forwarded message:
>
> > From: No Starch Press 
> > Subject: 40% Off Realm of Racket
> > Date: June 18, 2013 11:00:20 AM EDT
> >
> > Learn to Program, One Game at a Time!
> > Email look funny?
> > View it in your browser.
> >
> > 40% Off Realm of Racket
> >
> > For the next 72 hours, get 40% off Realm of Racket, and learn to program
> in Racket, one game at a time!
> >
> > Use coupon code RACKETEERS.
> >
> > Coupon good on print or ebook purchase. Print purchase includes DRM-free
> ebook (PDF, epub, and mobi).
> >
> >   Follow on Twitter   | Friend on Facebook   | Forward to a
> friend
> > No Starch Press
> > 38 Ringold Street
> > San Francisco, CA 94103
> >
> > Add us to your address book
> >
> >  Update subscription   |   Unsubscribe|   View in browser
> >
> >
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Problems compiling Racket 5.3.5 on OpenIndiana (core dump)

2013-08-14 Thread WarGrey Gyoudmon Ju
Hi, Oskarsson.

There is another way to build racket in OpenIndiana.

env CC="gcc -m64" configure ...

64-bit version is okay.


On Thu, Aug 15, 2013 at 4:00 AM, Johann 'Myrkraverk' Oskarsson <
myrkrav...@yahoo.com> wrote:

> Matthew Flatt  writes:
>
> > I've made places enabled by default for Solaris on x86/x86_64, and
> > I've also configured Racket to use large-chunk allocation on Solaris
> > when places are disabled.
>
> How can I take advantage of those changes?  Do I need to grab racket
> directly from source control?
>
>
> Johann
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Vim with mzscheme

2013-12-02 Thread WarGrey Gyoudmon Ju
These api binds are writen in c, if_mzsch.c in the source directory of vim.


On Sun, Dec 1, 2013 at 9:05 PM, Eduardo Costa  wrote:

> Well, I compiled Vim with mzscheme enabled. It works great. However, in
> the documentation, I found that mzscheme has a library called
> mzscheme-vimext that adds many Vim related commands to mzscheme. I could
> not find mzscheme-vimext anywhere. I mean, I couldn't find it in PLaneT, in
> the Vim distribution, etc.
>
> Can anybody provide a link to mzscheme-vimext?
>
> Thank you in advance.
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] DrRacket GUI tutorial with MVC concepts?

2013-12-17 Thread WarGrey Gyoudmon Ju
I think the guidelines of program racket is on the way.

http://www.ccs.neu.edu/home/matthias/Style/style/
This document does not discuss Classes too much.

Class in racket has its own power and is potential to improve right now.
But it *is* just an alternative way to program, in which case the knowledge
you need should learn from OOPLs.


On Wed, Dec 18, 2013 at 4:04 AM, Geoffrey S. Knauth wrote:

> Thanks, Janos.  He and I both have Realm of Racket, and love and
> appreciate it.  I think he kind of got MVC by osmosis, so it succeeded, it
> just struck me that he hadn't ever heard of MVC, and that made me wonder if
> PLT had a "philosophy" about systems building, given that PLT tools grow in
> capability and scalability every year.  It's OK if it doesn't, though I bet
> developers coming from other languages and frameworks will ask the same
> question.  I was just wondering.
>
> In fairness to my son, when I was his age in 1976, when I thought I knew
> everything (cough cough) — I didn't even know there were persons called
> Knuth, McCarthy, Church, Turing, ...
>
> In fairness to life, in the following decades I got to meet most of the
> living giants of the field, a field which continues to explode with
> surprises.
>
> Geoff
>
> On Dec 16, 2013, at 14:33 , Janos Tobias Locsei 
> wrote:
>
> > Geoff, maybe your son would enjoy the book "Realm of Racket" which
> teaches game programming in Racket? It teaches MVC by osmosis, i.e. MVC is
> not explicitly discussed but you learn to structure your code along those
> lines anyway. I'm about 1/3 of the way through the book and it's good fun.
> It's amazing how little code it takes to make the "snakes" game.
> >
> > Tobias
> >
> >
> > Date: Sat, 14 Dec 2013 13:05:16 -0500
> > From: "Geoffrey S. Knauth" 
> > To: users@racket-lang.org
> > Subject: [racket] DrRacket GUI tutorial with MVC concepts?
> >
> > My son, who I'm afraid/inspired to say is a DrRacket addict, in that he
> does much of his homework (physics, calculus, Latin, music, what-next...)
> in DrRacket, has read through the Racket GUI Toolkit docs at:
> >
> > http://docs.racket-lang.org/gui/
> >
> > and presto, he has an app that can conjugate or decline any number of
> Latin words in a window.  The window has tabs and buttons and text areas
> and all the good stuff the toolkit provides, but in talking with him I
> discovered he'd never heard about MVC.  Is there a Racket tutorial
> somewhere that goes into the proper MVC (or whatever you want to call it)
> approach in the context of building Racket applications?
> >
> > By the way, what does the Racket community call MVC?  I've seen other
> communities come up with their own terminology (e.g., [1]), and I don't
> know/remember if Racket has stayed with MVC or called it something else.
> >
> > Thanks,
> > Geoff
> >
> > [1]
> https://docs.djangoproject.com/en/dev/faq/general/#django-appears-to-be-a-mvc-framework-but-you-call-the-controller-the-view-and-the-view-the-template-how-come-you-don-t-use-the-standard-names
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Can I make the frame% instances transparent?

2014-01-18 Thread WarGrey Gyoudmon Ju
These days I am researching on a new Editor/IDE to take the place of Vim
and Emacs.
In order to learn programing languages(not only racket) deeply I won't make
it as the DrRacket's plugin.

I also like the transparent style in which way I use terminal so that I can
check resources at the same time when coding. Is there any direct way to
get it?

Racket provides lots of graphic documents, but I think they are not good
organised. Do (big-bang) and the HtDP teachpacks suitable to build real
world GUI applications?

Thanks in advance.

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Can I make the frame% instances transparent?

2014-01-20 Thread WarGrey Gyoudmon Ju
Thanks.
This saved lots of time.


On Mon, Jan 20, 2014 at 10:39 AM, Matthew Flatt  wrote:

> The `frame%` class does not offer a transparency option, but on Mac OS
> X, you can use the FFI to make a frame transparent at the Cocoa
> NSWindow layer.
>
> Here's an example:
>
> --
>
> #lang racket/gui
> (require ffi/unsafe
>  ffi/unsafe/objc)
>
> ;; Create the frame:
> (define f (new frame%
>[label "Example"]
>[width 200]
>[height 200]))
>
> ;; Add a transparent canvas that displays "Hello"
> (new canvas%
>  [parent f]
>  [style '(transparent)]
>  [paint-callback (lambda (c dc)
>(send dc draw-text "Hello" 0 0))])
>
> ;; The `CGFloat` type depends on the platform:
> (define 64-bit? (= (ctype-sizeof _long) 8))
> (define _CGFloat (if 64-bit? _double _float))
>
> ;; Get an `NSWindow` from the `frame%` object:
> (define h (send f get-handle))
>
> ;; Set the background's transparency at the `NSWindow` level:
> (import-class NSColor)
> (tellv h setBackgroundColor: (tell NSColor
>colorWithRed: #:type _CGFloat 1.0
>green: #:type _CGFloat 1.0
>blue: #:type _CGFloat 1.0
>alpha: #:type _CGFloat 0.5))
> (tellv h setOpaque: #:type _BOOL NO)
>
> ;; Show the frame:
> (send f show #t)
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Why Typed Racket is faster?

2014-02-23 Thread WarGrey Gyoudmon Ju
Does RVM  know the type information at runtime? Is typed racket just a
front-end parser (target to contracts)? In theory is it possible to
manually optimize untyped racket to make it as fast as the typed one in
most cases?

To ignore the developing features, do we lose any expressivenesses?

(lambda ([μ 0.0] [σ 1.0] #:multiple [p 1])
   (define samples (flnormal-sample μ σ p))
   (apply  values (flvector->list samples))

This example returns non-fix-length multiple values,  it seems impossible
to annotate its type.
It took me hours and hours to enumerate all possible ways but still
unsolved.

(define: random-gaussian : (case-> [[#:mean Flonum] [#:stddev Flonum]
[#:multiple False] -> Flonum]
   [[#:mean Flonum] [#:stddev Flonum]
[#:multiple Index] -> (Listof Flonum)])
  {lambda {#:mean [μ 0.0] #:stddev [σ 1.0] #:multiple [p #false]}
(define: samples : FlVector (flnormal-sample μ σ (if (false? p) 1 p)))
(cond [(false? p) (flvector-ref samples 0)]
  [else (flvector->list samples)])})

Actually, DrRacket complains about (Values Flonum)
So 'multiple values' is evil!

Keyword argument is also the optional one, it's good for stopping (case->)
becoming too complexity. But why not (false? p) tells Typed Racket to
choose the first function types?

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Why Typed Racket is faster?

2014-02-24 Thread WarGrey Gyoudmon Ju
Okay, thank you Vincent.
Typed Racket itself is a good Code Guide for untyped programs.


On Mon, Feb 24, 2014 at 10:24 PM, Vincent St-Amour wrote:

> At Mon, 24 Feb 2014 13:51:30 +0800,
> WarGrey Gyoudmon Ju wrote:
> > Does RVM  know the type information at runtime? Is typed racket just a
> > front-end parser (target to contracts)? In theory is it possible to
> > manually optimize untyped racket to make it as fast as the typed one in
> > most cases?
>
> Typed Racket operates entirely at macro-expansion time. By the time the
> Racket compiler sees a Typed Racket program, the types are all gone.
>
> Typed Racket's optimizer simply rewrites operations to use unsafe
> type-specific operations provided by Racket (see racket/unsafe/ops),
> something you could do by hand if you wanted. TR also does some other
> optimizations (scalar replacement, dead code elimination, etc.) which
> you could also do by hand.
>
> There are some advantages at having TR do it for you, though. First,
> modulo bugs in TR, these "unsafe" operations are actually guaranteed to
> actually be safe by the typechecker. If you manually add unsafe
> operations, you may accidentally introduce segfaults. Second, TR
> typechecks (and optimizes) code after macros are expanded, and so it can
> optimize inside the expansion of macros, which you can't do at the
> source level.
>
> > To ignore the developing features, do we lose any expressivenesses?
> >
> > (lambda ([μ 0.0] [σ 1.0] #:multiple [p 1])
> >(define samples (flnormal-sample μ σ p))
> >(apply  values (flvector->list samples))
> >
> > This example returns non-fix-length multiple values,  it seems impossible
> > to annotate its type.
>
> That does indeed look like something TR does not support.
>
> However, functions that return a variable number of values are often
> (IMO) questionable design. I would recommend rewriting your code to
> return a collection instead (and would recommend that even if TR was not
> involved).
>
> > It took me hours and hours to enumerate all possible ways but still
> > unsolved.
> >
> > (define: random-gaussian : (case-> [[#:mean Flonum] [#:stddev Flonum]
> > [#:multiple False] -> Flonum]
> >[[#:mean Flonum] [#:stddev Flonum]
> > [#:multiple Index] -> (Listof Flonum)])
> >   {lambda {#:mean [μ 0.0] #:stddev [σ 1.0] #:multiple [p #false]}
> > (define: samples : FlVector (flnormal-sample μ σ (if (false? p) 1
> p)))
> > (cond [(false? p) (flvector-ref samples 0)]
> >   [else (flvector->list samples)])})
> >
> > Actually, DrRacket complains about (Values Flonum)
> > So 'multiple values' is evil!
> >
> > Keyword argument is also the optional one, it's good for stopping
> (case->)
> > becoming too complexity. But why not (false? p) tells Typed Racket to
> > choose the first function types?
>
> That's odd. I'll look into it.
>
> Vincent
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Racket 6.0 does not work

2014-03-09 Thread WarGrey Gyoudmon Ju
Hi Junia.
I am an OpenIndiana User, Racket is the most easiest (big) language to
build in Solaris and its forks, and it works no difference from it in other
operating systems.
In OpenIndiana even guile I cannot build without pain.

I was a vim+mzscheme user, I built it in MacOSX in which platform vim needs
something call Racket.Framework, one additional step is to create a soft
link in Mac's default framework directory (I did not install racket in the
default location). Yes, it fails in 5.3.6, since vim configure/makefile
does not use the correct way to search collection path, and the solution is
easy, you can find it in this list.




On Thu, Mar 6, 2014 at 5:03 AM, Junia Magellan  wrote:

> I am a professor of Computer Science in a technological institute. My
> research is comparing productivity of computer languages using Measurement
> Theory. I think you already know that from my previous posts. The point is
> that Racket 6.0 installer is very unfriendly. Well, it is almost like the
> installer of Racket 6.0. The only difference is that Racket 6.0 does not
> work.
>
> I asked about 8 students to install Racket 6.0. Nobody succeeded. 100% of
> failures. I tried the installation myself, and failed. I will give an
> example.  I am using Cloud computing, and cannot modify the machine. For
> instance, I cannot install a new operating system to satisfy the
> requirements of Racket 6.0. Given these constraints, the situation is the
> following:
>
> cat /proc/cpuinfo
>
> vendor_id: AuthenticAMD
> cpu family: 21
> model: 2
> model name: AMD Opteron 63xx class CPU
> stepping: 0
> microcode: 0x165
> cpu MHz: 2299.909
> cache size: 512 KB
> fpu: yes
> fpu_exception: yes
> cpuid level: 13
> wp: yes
> bogomips: 4599.81
> TLB size: 1024 4K pages
> clflush size: 64
> cache_alignment: 64
> address sizes: 48 bits physical, 48 bits virtual
>
> This particular machine has 16 cores, and the kernel is:
>
> uname -mrs
> Linux 3.2.52 x86_64
>
> When I try to run Racket 5.36, everything works perfectly well. Here is an
> example:
>
> # mv racket racket60
> # mv racket-old/ racket
> # racket/bin/racket -il xrepl
> Welcome to Racket v5.3.6.
> -> (* 3 4 5)
> 60
> -> (exit)
>
> Now, let us see what happens with Racket 6.0:
>
> # mv racket racket-old
> # mv racket60 racket
> # mv racket60 racket
> # racket/bin/racket
> racket/bin/racket: /lib64/libc.so.6: version `GLIBC_2.14' not found
> (required by racket/bin/racket)
> #
>
> I would like you to understand that most people are not PhD in Computer
> Science. 90% of people want to run out of the box applications. Even
> programmers don't have in depth knowledge about the workings of computers
> and operating systems. I don't know why Racket 6.0 needs libc.so.6, or
> GLIBC_2.14. I just want to run statistics programs written in Racket from
> an Internet page.
>
> I will give you another example about Racket 6.0. There are a lot of
> people that use a text editor called Vim+mzscheme. This text editor has a
> lot of applications about Rasch measurement, that are used by people in the
> business of education. I mean, people who work in things like SAT, GRE,
> USMLE, and equivalent activities in countries around the world. These
> programs test students, and the processed scores are often used by
> admission offices to accept applicants. I happen to work with this kind of
> programs.
>
> Installing Vim+mzscheme is a nuisance, since people must compile Racket
> from sources, and Vim from sources. In Windows, few people succeed in
> performing the task. The same is true in the case of OS-X. I am talking
> about Racket 5.36, for I don't know a single person who installed
> vim+mzscheme with Racket 6.0.
>
> What I need is a version of Racket that work right out of the box, at
> least for OS-X, Windows 7, Windows 8, and Linux. I also need a fast editor,
> like Vim.
>
> Well members of this list, here is what I am going to do. I will download
> Bigloo, learn how to use it, hire a programmer to write array operations in
> Bigloo, translate a lot of programs from Racket and Common Lisp to Bigloo,
> and start from zero, as in Edith Piaf's song.
>
>
>
>
>
> * Junia Magalhães Rocha*
>
> Doutoranda em Inteligência Artificial - Engenharia Elétrica - UFU
> Mestre em Inteligência Artificial - Ciência da Computação - UFU
>
> Docente do IFTM - Campus Avançado Patrocínio
>
> Lattes: http://lattes.cnpq.br/3659680417351721
>
>
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Non-in-place installs for Racket from git

2014-03-15 Thread WarGrey Gyoudmon Ju
Hi Asumu.
This is a development version.
Now I figure out that, git version is in its way to support class system in
Typed Racket,
but  `raco install` via downloading only have the stable packages for
stable versions.

So the only way to use git version is building packages via `raco install
--link`,
Checking the INSTALL.txt in the top level directory.


On Sun, Mar 16, 2014 at 1:25 PM, Asumu Takikawa  wrote:

> Hi all,
>
> Is there a good way to do non-in-place installs with Racket from git
> HEAD?
>
> When this was brought up previously on the mailing list, it was
> suggested to build a base Racket install and then to use `raco pkg
> install` to install the rest of the main distribution from the network.
>
> Unfortunately, this isn't a great solution for my use-case: I'm trying
> to automate Racket builds for a VM image with Docker. Downloading all of
> the packages (1) takes a long time, which seems especially wasteful
> since I've already cloned from github, and (2) is more susceptible to
> network failure.
>
> (#2 is not a theoretical concern. I've had the build process fail twice
>  due to a single package failing to download.)
>
> On a side note, I also got the following error while running
> `raco pkg install -i --auto main-distribution` when compiling the
> collects:
>
>   usr/share/racket/pkgs/compatibility-lib/mzlib/class.rkt:1:0: module:
> provided identifier not defined or imported for phase 0
> at: ->dm
> in: (#%plain-module-begin (#%require (for-syntax mzscheme)) (require
> racket/private/class-internal) (provide-public-names))
> context...:
>  standard-module-name-resolver
>  standard-module-name-resolver
>  standard-module-name-resolver
>   /usr/share/racket/collects/setup/setup-core.rkt:59:0: setup-core
>  /usr/share/racket/collects/setup/setup.rkt:56:3
>  /usr/share/racket/collects/pkg/main.rkt:16:0: setup
>  (submod /usr/share/racket/collects/pkg/main.rkt main): [running body]
>  /usr/share/racket/collects/pkg/raco.rkt: [traversing imports]
>  /usr/share/racket/collects/raco/raco.rkt: [running body]
>  /usr/share/racket/collects/raco/main.rkt: [running body]
>
> Could that be due to a dependency issue or something?
>
> Cheers,
> Asumu
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Non-in-place installs for Racket from git

2014-03-16 Thread WarGrey Gyoudmon Ju
Yes, it works now.
Thanks, Matthew.


On Sun, Mar 16, 2014 at 8:26 PM, Matthew Flatt  wrote:

> At Sun, 16 Mar 2014 14:44:27 +0800, WarGrey Gyoudmon Ju wrote:
> > Now I figure out that, git version is in its way to support class system
> in
> > Typed Racket,
> > but  `raco install` via downloading only have the stable packages for
> > stable versions.
>
> Just to clarify, `raco pkg install` should work now that the
> package-extraction service is restored.
>
> If you use `raco pkg install` from a v6.0 distribution, it should still
> get the old package version, because the distribution is configured to
> check a v6.0-specific catalog first.
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Maybe a mistake in typed/file/gif.rkt

2014-03-28 Thread WarGrey Gyoudmon Ju
 Type mismatch of (gif-start)

  [gif-start ( Output-Port Number Number Number (U #f (Listof (Vectorof
Number))) -> Void )]

It should return GIF-Stream.

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] [racket-users]Is Racklog suitable to learn Prolog? A simple example just fails.

2014-07-02 Thread WarGrey Gyoudmon Ju
This example is rewritten from the datalog version.

#lang racket

(require racklog)

(define %edge
  (%rel ()
[('a 'b)]
[('b 'c)]
[('c 'd)]
[('d 'a)]))

(define %path
  (%rel (X Y)
[(X Y) (%edge X Y)]
[(X Y) (%edge X 'Z)
 (%path 'Z Y)]))

(%find-all (X Y) (%path X Y))

It only gives four results.

#lang racklog

edge(a, b).
edge(b, c).
edge(c, d).
edge(d, a).

path(X, Y) :- edge(X, Y).
path(X, Y) :- edge(X, Z), path(Z, Y).

path(X, Y)?

and this version will not terminate.

Thanks in advance.

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] [racket-users]Is Racklog suitable to learn Prolog? A simple example just fails.

2014-07-03 Thread WarGrey Gyoudmon Ju
Sorry, my example is not correct.
But this one still does not work:

#lang at-exp racket

(require racklog)

(define %edge
  (%rel ()
[('a 'b)]
[('b 'c)]
[('c 'd)]
[('d 'a)]))

(define %path
  (%rel (X Y Z)
[(X Y) (%edge X Y)]
[(X Y) (%edge X Z) (%path Z Y)]))

(let answer ([r (%which (X Y) (%path X Y))])
  (printf "~a --> ~a~n" (cdar r) (cdadr r))
  (answer (%more)))

This version also will not terminate.

On Thu, Jul 3, 2014 at 9:04 PM, Matthias Felleisen 
wrote:

>
> If you want to learn Prolog, why not use a free Prolog implementation?


Simply speaking, Modern Prolog seems to cut the illumos-based SunOS off, I
cannot build it without headache and they does not answer me about this
issue.
So I wander if Racklog is a legacy package?


>
> If you want to learn about relational programming, use miniKanren, which
> is available of cKanren. Then you can also get to constraints. Maintainer
> cc-ed.
>
> -- Matthias
>
>
>
> On Jul 3, 2014, at 6:48 AM, WarGrey Gyoudmon Ju wrote:
>
> > This example is rewritten from the datalog version.
> >
> > #lang racket
> >
> > (require racklog)
> >
> > (define %edge
> >   (%rel ()
> > [('a 'b)]
> > [('b 'c)]
> > [('c 'd)]
> > [('d 'a)]))
> >
> > (define %path
> >   (%rel (X Y)
> > [(X Y) (%edge X Y)]
> > [(X Y) (%edge X 'Z)
> >  (%path 'Z Y)]))
> >
> > (%find-all (X Y) (%path X Y))
> >
> > It only gives four results.
> >
> > #lang racklog
> >
> > edge(a, b).
> > edge(b, c).
> > edge(c, d).
> > edge(d, a).
> >
> > path(X, Y) :- edge(X, Y).
> > path(X, Y) :- edge(X, Z), path(Z, Y).
> >
> > path(X, Y)?
> >
> > and this version will not terminate.
> >
> > Thanks in advance.
> > 
> >  Racket Users list:
> >  http://lists.racket-lang.org/users
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] [racket-users]Is Racklog suitable to learn Prolog? A simple example just fails.

2014-07-03 Thread WarGrey Gyoudmon Ju
Okay, Thank you.


On Fri, Jul 4, 2014 at 1:21 AM, Matthias Felleisen 
wrote:

>
> Yes, I corrected your program and ran into this bug.
>
> Try to use Kanren instead of Racklog. It isn't completely a legacy package
> but I doubt we can get a quick fix here.
>
> -- Matthias
>
>
>
>
> On Jul 3, 2014, at 4:53 PM, WarGrey Gyoudmon Ju wrote:
>
> Sorry, my example is not correct.
> But this one still does not work:
>
> #lang at-exp racket
>
> (require racklog)
>
> (define %edge
>   (%rel ()
> [('a 'b)]
> [('b 'c)]
> [('c 'd)]
> [('d 'a)]))
>
> (define %path
>   (%rel (X Y Z)
> [(X Y) (%edge X Y)]
> [(X Y) (%edge X Z) (%path Z Y)]))
>
> (let answer ([r (%which (X Y) (%path X Y))])
>   (printf "~a --> ~a~n" (cdar r) (cdadr r))
>   (answer (%more)))
>
> This version also will not terminate.
>
> On Thu, Jul 3, 2014 at 9:04 PM, Matthias Felleisen 
> wrote:
>
>>
>> If you want to learn Prolog, why not use a free Prolog implementation?
>
>
> Simply speaking, Modern Prolog seems to cut the illumos-based SunOS off, I
> cannot build it without headache and they does not answer me about this
> issue.
> So I wander if Racklog is a legacy package?
>
>
>>
>> If you want to learn about relational programming, use miniKanren, which
>> is available of cKanren. Then you can also get to constraints. Maintainer
>> cc-ed.
>>
>> -- Matthias
>>
>>
>>
>> On Jul 3, 2014, at 6:48 AM, WarGrey Gyoudmon Ju wrote:
>>
>> > This example is rewritten from the datalog version.
>> >
>> > #lang racket
>> >
>> > (require racklog)
>> >
>> > (define %edge
>> >   (%rel ()
>> > [('a 'b)]
>> > [('b 'c)]
>> > [('c 'd)]
>> > [('d 'a)]))
>> >
>> > (define %path
>> >   (%rel (X Y)
>> > [(X Y) (%edge X Y)]
>> > [(X Y) (%edge X 'Z)
>> >  (%path 'Z Y)]))
>> >
>> > (%find-all (X Y) (%path X Y))
>> >
>> > It only gives four results.
>> >
>> > #lang racklog
>> >
>> > edge(a, b).
>> > edge(b, c).
>> > edge(c, d).
>> > edge(d, a).
>> >
>> > path(X, Y) :- edge(X, Y).
>> > path(X, Y) :- edge(X, Z), path(Z, Y).
>> >
>> > path(X, Y)?
>> >
>> > and this version will not terminate.
>> >
>> > Thanks in advance.
>> > 
>> >  Racket Users list:
>> >  http://lists.racket-lang.org/users
>>
>>
>
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] [racket-users]Is Racklog suitable to learn Prolog? A simple example just fails.

2014-07-04 Thread WarGrey Gyoudmon Ju
Under standard prolog semantics Racklog is right.
The semantics between prolog and datalog is different.
Okay, thank you for pointing me.


On Fri, Jul 4, 2014 at 11:37 AM, Scott Moore 
wrote:

> I'm not sure what behavior you were expecting for this program. Under
> standard prolog semantics (goal-directed) this program will yield
> infinitely many solutions, so this may not be a bug in racklog but rather
> in the program.
>
> That said, Matthias is probably right that using a currently maintained
> package is probably a good idea.
>
> Cheers,
> Scott
>
>
> On Thu, Jul 3, 2014 at 7:46 PM, WarGrey Gyoudmon Ju  > wrote:
>
>> Okay, Thank you.
>>
>>
>> On Fri, Jul 4, 2014 at 1:21 AM, Matthias Felleisen 
>> wrote:
>>
>>>
>>> Yes, I corrected your program and ran into this bug.
>>>
>>> Try to use Kanren instead of Racklog. It isn't completely a legacy
>>> package but I doubt we can get a quick fix here.
>>>
>>> -- Matthias
>>>
>>>
>>>
>>>
>>> On Jul 3, 2014, at 4:53 PM, WarGrey Gyoudmon Ju wrote:
>>>
>>> Sorry, my example is not correct.
>>> But this one still does not work:
>>>
>>> #lang at-exp racket
>>>
>>> (require racklog)
>>>
>>> (define %edge
>>>   (%rel ()
>>> [('a 'b)]
>>> [('b 'c)]
>>> [('c 'd)]
>>> [('d 'a)]))
>>>
>>> (define %path
>>>   (%rel (X Y Z)
>>> [(X Y) (%edge X Y)]
>>> [(X Y) (%edge X Z) (%path Z Y)]))
>>>
>>> (let answer ([r (%which (X Y) (%path X Y))])
>>>   (printf "~a --> ~a~n" (cdar r) (cdadr r))
>>>   (answer (%more)))
>>>
>>> This version also will not terminate.
>>>
>>> On Thu, Jul 3, 2014 at 9:04 PM, Matthias Felleisen >> > wrote:
>>>
>>>>
>>>> If you want to learn Prolog, why not use a free Prolog implementation?
>>>
>>>
>>> Simply speaking, Modern Prolog seems to cut the illumos-based SunOS off,
>>> I cannot build it without headache and they does not answer me about this
>>> issue.
>>> So I wander if Racklog is a legacy package?
>>>
>>>
>>>>
>>>> If you want to learn about relational programming, use miniKanren,
>>>> which is available of cKanren. Then you can also get to constraints.
>>>> Maintainer cc-ed.
>>>>
>>>> -- Matthias
>>>>
>>>>
>>>>
>>>> On Jul 3, 2014, at 6:48 AM, WarGrey Gyoudmon Ju wrote:
>>>>
>>>> > This example is rewritten from the datalog version.
>>>> >
>>>> > #lang racket
>>>> >
>>>> > (require racklog)
>>>> >
>>>> > (define %edge
>>>> >   (%rel ()
>>>> > [('a 'b)]
>>>> > [('b 'c)]
>>>> > [('c 'd)]
>>>> > [('d 'a)]))
>>>> >
>>>> > (define %path
>>>> >   (%rel (X Y)
>>>> > [(X Y) (%edge X Y)]
>>>> > [(X Y) (%edge X 'Z)
>>>> >  (%path 'Z Y)]))
>>>> >
>>>> > (%find-all (X Y) (%path X Y))
>>>> >
>>>> > It only gives four results.
>>>> >
>>>> > #lang racklog
>>>> >
>>>> > edge(a, b).
>>>> > edge(b, c).
>>>> > edge(c, d).
>>>> > edge(d, a).
>>>> >
>>>> > path(X, Y) :- edge(X, Y).
>>>> > path(X, Y) :- edge(X, Z), path(Z, Y).
>>>> >
>>>> > path(X, Y)?
>>>> >
>>>> > and this version will not terminate.
>>>> >
>>>> > Thanks in advance.
>>>> > 
>>>> >  Racket Users list:
>>>> >  http://lists.racket-lang.org/users
>>>> <https://urldefense.proofpoint.com/v1/url?u=http://lists.racket-lang.org/users&k=AjZjj3dyY74kKL92lieHqQ%3D%3D%0A&r=HSKF6zsWgVGxFXZ9yyuTrGxfxvWcBXEsUbj4zoaWV4M%3D%0A&m=ueJMPMBM%2B38vGv%2FQ4VGiv1iOnLuujJtGYjC98mcEH4k%3D%0A&s=63daad8e5afeca69fe348a0517fbfc586b2831b5a89af8dd27931ceecb5bf0e6>
>>>>
>>>>
>>>
>>>
>>
>> 
>>   Racket Users list:
>>   http://lists.racket-lang.org/users
>>
>>
>

  Racket Users list:
  http://lists.racket-lang.org/users


[racket] Is there any particular reasons that Markdown-render does not deal with images?

2015-01-02 Thread WarGrey Gyoudmon Ju
As the title says. Why?

At least something like ![](already-exists-image-url) is neccessary.

Thanks in advance.

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket] Is there any particular reasons that Markdown-render does not deal with images?

2015-01-02 Thread WarGrey Gyoudmon Ju
On Sat, Jan 3, 2015 at 9:13 AM, Greg Hendershott 
wrote:

> > As the title says. Why?
> >
> > At least something like ![](already-exists-image-url) is neccessary.
>
> Why:
>
> 1. I didn't know how.
>
> At the time, I wasn't sure how to handle Scribble images generally.
> And I wasn't aware of the special case you mention, that Scribble lets
> you link to external image URLs. (Actually, does it? I don't know.)
>

Yes, URLs are there.
I  am just filled with curiosity because image links and URL links are
quite familiar.


>
> 2. It didn't seem important.
>
> At the time, the new package system didn't have a way to host
> documentation like PLaneT did. My motivation for doing this was that
> it could help to generate README.md files for GitHub. (And none of the
> package docs I looked at used images.) Anyway, these days
> pkgs.racket-lang.org does now build and host full Scribble doc HTML.
>

Actually I also prefer Scribble HTMLs, and I also just want to make
github.com happy.
Hmm, giving it an elegant README.md (display a pictorial project map for
instance).

Once I had decided to make a render for github.com to handle README.scrbl
directly.
But this goal requires Racket itself, perhaps they wouldn't care.

So. this topic is less important at the moment.
Thank you and sorry for taking your time.

  Racket Users list:
  http://lists.racket-lang.org/users


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

2015-02-21 Thread WarGrey Gyoudmon Ju
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


Re: [racket] scribble and .gitignore

2015-03-14 Thread WarGrey Gyoudmon Ju
I use ./compiled as the dest directory so that all generated files can be
omitted in .gitignore once and for all.



On Sun, Mar 15, 2015 at 1:30 AM, Jon Zeppieri  wrote:

> I've been looking at the .gitignore files in various racket packages,
> and the ones I've seen don't ignore files generated by scribble (.html
> .css, etc.). So what is the common practice for keeping those files
> out of source control?
> 
>   Racket Users list:
>   http://lists.racket-lang.org/users
>

  Racket Users list:
  http://lists.racket-lang.org/users


Re: [racket-users] Organizing tests

2015-04-19 Thread WarGrey Gyoudmon Ju
Thank you Matthias
This suggestion has enlightened me.
I did not figure out a good way to filter tests based on their types.

and, Konrad.
I have a makefile.rkt to help me (and potential cooperators) build the
system.
The *scribble/lp* plays an important role in my development process
not only because it can produce beautiful test report,
but also as a hybrid of natural documentation and formal specification.
The entry *scrbl *ensures that all testsuites or testcases are ordered
logically.

Moreover, to follow the Behavioral driven development (or just "Test
First") principle,
module sources can keep elegant on their own.


This does require some additional work to do, but I think it's worth doing.


On Thu, Apr 16, 2015 at 11:28 PM, Matthias Felleisen 
wrote:

>
> Use different names for the various test modules.
> At the local level, you can use module+ test. For
> the integration tests, you may wish to use module+
> integration. Then run raco test with the parameter
> that takes the name of the submodule you want. (If
> you really want to run unit tests together with
> integration tests, import the former into the latter.)
>
> -- Matthias
>
>
>
> On Apr 16, 2015, at 11:17 AM, Konrad Hinsen wrote:
>
> > Hi everyone,
> >
> > I want to put some order into my tests, but after looking at various
> > published Racket packages, I am not sure if there any accepted "best
> > practices".
> >
> > For a single module, the best approach seems to be a submodule "test"
> > for the test cases, which are then run by "raco test". That's nice and
> > works fine.
> >
> > But what I have is a collection with multiple modules. Each modules
> > has local tests, but there are also tests at a higher level that use
> > code from several modules.
> >
> > I am looking for an approach that lets me run either all tests in my
> > collection, or convenient subsets (e.g. one module), ideally using a
> > single tool such as "raco test". Any suggestions? You get bonus points
> > for solutions that integrate well with racket-mode in Emacs.
> >
> > Thanks in advance,
> >  Konrad.
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and stop receiving emails from it, send
> an email to racket-users+unsubscr...@googlegroups.com.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and 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] convert to/from Sribble

2015-04-22 Thread WarGrey Gyoudmon Ju
I use Scribble heavily every day.

One question with the default Markdown renderer is it breaks line every 72
chars when rendering blocks,
and this poor implementation totally messes up the resulting file.

On Wed, Apr 22, 2015 at 11:13 PM, Neil Van Dyke 
wrote:

> Here's an interface for using your own renderers with Scribble:
> http://docs.racket-lang.org/scribble/renderer.html
>
> I think one would also want to look at the code for an existing renderer,
> not just work from the interface documentation alone.  (If I were going to
> do a more-plain-HTML5 renderer, my first pass would be to copy the existing
> HTML renderer, and start modifying it until I had a working
> proof-of-concept for my desired output format.  This might be very easy.
> After that, armed with my new understanding, I would probably then look at
> how to share code with between the two HTML flavors of rendering, to have
> things be more maintainable long-term.)
>
> 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.


[racket-users] [racket][off-topic] what's the official meaning of *.rktl and *.rktd?

2015-05-10 Thread WarGrey Gyoudmon Ju
Sorry it's hard to find the official definition of **.rktl* and **.rktd*
except both of them are racket source file extensions as well as **.rkt*.
My dim memory shows that *l* means *load* or *link*? *d* means *D**rRacket*?
and these two ones are used for configuration.

In my web htdocs, there are *servlet*.*rkt*, *literate-programming.**rkt *
and *s-exp-configuration*.*rkt*. That would be great if they all have a
conventional file extension instead of randomly choosing one on my 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][off-topic] what's the official meaning of *.rktl and *.rktd?

2015-05-10 Thread WarGrey Gyoudmon Ju
Get it!
Thank you Sam.

On Mon, May 11, 2015 at 9:53 AM, Sam Tobin-Hochstadt 
wrote:

> .rktl is for files intended to be used with 'load', which is what the l
> stands for.
>
> .rktd is for files used with 'read', and the d stands for data.
>
> Sam
>
> On Sun, May 10, 2015, 9:40 PM WarGrey Gyoudmon Ju 
> wrote:
>
>> Sorry it's hard to find the official definition of **.rktl* and **.rktd*
>> except both of them are racket source file extensions as well as **.rkt*.
>> My dim memory shows that *l* means *load* or *link*? *d* means *D*
>> *rRacket*? and these two ones are used for configuration.
>>
>> In my web htdocs, there are *servlet*.*rkt*, *literate-programming.**rkt
>> *and *s-exp-configuration*.*rkt*. That would be great if they all have a
>> conventional file extension instead of randomly choosing one on my 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.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and 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][web] How to make security-guard work with servlets

2015-05-20 Thread WarGrey Gyoudmon Ju
Hello Jay, and Racketeers.

What the original problem is:
I want my pure Racket Web Server listens on port 80, and this server allows
per-user dynamic content.



As a security problem, no comprehensive solutions exists, it is a big topic
of system administration. In real world, the racket web servers work as
application server behind apache/nginx is a common sense in which case they
can listen on un-privileged port.

This is fine, but in a multi-user system, un-privileged port can still be
replaced by other non-root users, and run as root does not as unsafe as it
sounds like.

So l'd like to do it the hard way, although Racket as well as Java cannot
take advantages of the user-permission APIs. However, wrap the servlet
dispatcher with a security guarder does not work. I have no idea if I
misunderstand this feature.

Thanks in advance.

Links: Apache Security and Solutions
https://www.feistyduck.com/library/apache-security/online/apachesc-CHP-6.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.


[racket-users] Re: [racket][web] How to make security-guard work with servlets

2015-05-20 Thread WarGrey Gyoudmon Ju
On Wed, May 20, 2015 at 7:09 PM, Jay McCarthy 
wrote:

> The Racket feature of a 'security guard' is not what you want, I
> think. It prevents a block of Racket code from doing things like
> accessing the file system or the network. It is used, for example, by
> evaluation sandboxes to protect against un-trusted user code. I don't
> think you want to run your code that way.
>
> One thing that you could do is start the program as root, then call
> setguid and setuid (after binding them [very simple] with the FFI).
> This is a pretty standard practice. You'd put it after the bind
> message is returned from the Web server.
>
>
Oh Great, this is exactly what I want.
Thank you Jay.



> Jay
>
> On Wed, May 20, 2015 at 6:26 AM, WarGrey Gyoudmon Ju
>  wrote:
> > Hello Jay, and Racketeers.
> >
> > What the original problem is:
> > I want my pure Racket Web Server listens on port 80, and this server
> allows
> > per-user dynamic content.
> >
> >
> >
> > As a security problem, no comprehensive solutions exists, it is a big
> topic
> > of system administration. In real world, the racket web servers work as
> > application server behind apache/nginx is a common sense in which case
> they
> > can listen on un-privileged port.
> >
> > This is fine, but in a multi-user system, un-privileged port can still be
> > replaced by other non-root users, and run as root does not as unsafe as
> it
> > sounds like.
> >
> > So l'd like to do it the hard way, although Racket as well as Java cannot
> > take advantages of the user-permission APIs. However, wrap the servlet
> > dispatcher with a security guarder does not work. I have no idea if I
> > misunderstand this feature.
> >
> > Thanks in advance.
> >
> > Links: Apache Security and Solutions
> >
> https://www.feistyduck.com/library/apache-security/online/apachesc-CHP-6.html
>
>
>
> --
> Jay McCarthy
> 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&C 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.


Re: [racket-users] test submodules vs tests in separate file

2015-05-22 Thread WarGrey Gyoudmon Ju
On Fri, May 22, 2015 at 5:41 PM, Atticus  wrote:

>
> Imho it would be nice if there was a small hint in the documentation
> about that case, perhaps there is and I didn't see it?


Yes, there is :
http://docs.racket-lang.org/style/Units_of_Code.html?q=define%2Fcontract#%28part._.Contracts%29


In practice, I design tests in a system level abstraction.

black-box tests are always embedded in documentation so that
if the documentation does not show errors, then the system is reasonably
correct (for bugs that already found).
source code can keep elegant, and leave all the dirty things to scribble.

I almost do not write white-box tests since Racket and Typed Racket itself
has already formal enough,
moreover these tests or verifications can also be moved to documentation if
needed.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and 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] exn->string

2015-05-26 Thread WarGrey Gyoudmon Ju
I think user-friendly 500 page should be designed separately just as web
devs do for 404 page.
In practice, a user happens to meet an uncaught runtime exception, and he's
browsing a buggy website,
perhaps he do not have the will to report the problem, nor the way to
report it.
Finally, devs will fix it certainly by checking a place, say, logging
system, where saved this exception
rather than asking user for the screen snapshot.

So I think it's devs' fault if they forget to hide their exceptions.
This situation should never happen in a high-value project.



On Mon, May 25, 2015 at 11:16 PM, Greg Hendershott <
greghendersh...@gmail.com> wrote:

> Maybe I'm over-thinking this and/or misunderstanding the use case, but:
>
> Should there maybe be a parameter to control whether exn->string
> returns anything interesting? And, should it be #f by default?
>
>
> Roughly, for example:
>
> ;; When current-exn->string-enabled? is #f -- the default --
> ;; exn->string simply returns "error".
> ;;
> ;; (The idea here is that net apps shouldn't provide this information
> ;; by default, exn->string is probably being used to provide "debug
> ;; info", and this should be enabled intentionally not by default.)
> (define current-exn->string-enabled? (make-parameter #f))
>
> ;; exn->string : (or/c exn any) -> string
> (define (exn->string exn)
>   (cond [(not (current-exn->string-enabled?)) "error"]
> [(exn? exn) (parameterize ([current-error-port
> (open-output-string)])
>   ((error-display-handler) (exn-message exn) exn)
>   (get-output-string (current-error-port)))]
> [else (format "~s\n" exn
>
>
> Admittedly, just because there's a switch to turn it on and off,
> doesn't mean people will use it. (Source: Use the web for a week and
> encounter .NET apps deployed to show debug stack traces on error.)
> But there should be a switch, so that people can forget to use it. :)
>
> Admittedly, most Racket web apps are probably not high-value targets,
> today. But they ought to be someday, so why not plan for that?
>
> Again, I'm sorry if I'm over-thinking this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and 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] Cover 2.0

2015-05-31 Thread WarGrey Gyoudmon Ju
Would you like to provide an example.
Say, it can produce an HTML page,
it would be better if your repo can show what it looks like finally.

On Sun, May 31, 2015 at 9:51 AM, Spencer Florence 
wrote:

> Whoops, sorry! Knew we forgot something... Sorry about that!
>
> Cover is a multi-file code coverage tool, designed to work like `raco
> test`.
>
> On Sat, May 30, 2015 at 8:36 PM Hendrik Boom 
> wrote:
>
>> On Sat, May 30, 2015 at 06:00:06PM +, Spencer Florence wrote:
>> > Hi All,
>> >
>> > We're pleased to announce the release of Cover 2.0!
>>
>> May I suggest that whenever anyone announces a new release of any
>> software,
>> that the announcement contains a brief description of what that software
>> is intended to do, rather than just stating a few new features o fthe new
>> release?
>>
>> -- hendrik
>>
>> >
>> > Along with the various bug fixes, Cover now:
>> >
>> > * Is faster.
>> > * Is completely thread safe.
>> > * Has a new, easier to use, Racket API. This is to support integrating
>> with
>> > IDE's and make new output formats easier to write.
>> >
>> > New contributors are always welcome!
>> > If you find bugs, you can open an issue at
>> > https://github.com/florence/cover/issues.
>> > In addition, if there are any new output formats, tools, or services
>> that
>> > you think should be added, open an issue.
>> >
>> > Thanks!
>> >
>> > --Spencer & Ryan
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> Groups "Racket Users" group.
>> > To unsubscribe from this group and stop receiving emails from it, send
>> an email to racket-users+unsubscr...@googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>  --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and 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] Does scribble/lp2 allow for test submodule

2015-06-02 Thread WarGrey Gyoudmon Ju
Yes, you can. I do it all the time.

BTW, lp2 is just the lp except that you do not need to wrap it in another
scribble file before requiring.

On Tue, Jun 2, 2015 at 8:43 PM, Tim Brown  wrote:

> In the distant past, I tried to use `scribble/lp' with a program with a
> `test' sub-module (using that common pattern). There was some issue
> with exporting the module that meant that I could not do it.
>
> Now, in 2015, I notice that:
>  a. time has passed, things have developed
>  b. there is a `scribble/lp2' language
>
> Is it now possible to write test cases in a `test' sub-module of a
> literate program for testing with `raco test'?
>
> Tim
>
> --
> 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.


[racket-users] [racket][system] Web server does not sleep when idling in Solaris/OpenIndiana

2015-06-18 Thread WarGrey Gyoudmon Ju
Hello.

This is in OpenIndiana.
I found the web server does not want to sleep after handling at least one
requests.
Mostly, it just load the entire core, sometimes it keeps increasing with
handling few requests,

but there seems one exception,
if the client is net/http-client (rather than curl, w3m or any other
browsers)
then all is well, the server will sleep as expected.

BTW, it seems that Racket does not run in Solaris as efficient as in other
mainstream
systems.

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.


[racket-users] Re: [racket][system] Web server does not sleep when idling in Solaris/OpenIndiana

2015-06-30 Thread WarGrey Gyoudmon Ju
Finally I found the root cause is that pollsys is called too frequently.
and this problem seems quite normal in Solaris family.

I don't think I can solve it on my own,
Solaris-specific JVM provides an option `PerfDataSamplingInterval` as a
workaround.
Meanwhile I have to restart the daemon as long as it is busy in doing
nothing worthy.

and more, I have no idea if it would be better to use some other event
completion frameworks (say, port_create and friends)
to take the place of poll(2)/poll(7d).


On Thu, Jun 18, 2015 at 10:17 PM, WarGrey Gyoudmon Ju  wrote:

> Hello.
>
> This is in OpenIndiana.
> I found the web server does not want to sleep after handling at least one
> requests.
> Mostly, it just load the entire core, sometimes it keeps increasing with
> handling few requests,
>
> but there seems one exception,
> if the client is net/http-client (rather than curl, w3m or any other
> browsers)
> then all is well, the server will sleep as expected.
>
> BTW, it seems that Racket does not run in Solaris as efficient as in other
> mainstream
> systems.
>
> 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.


Re: [racket-users] Re: [racket][system] Web server does not sleep when idling in Solaris/OpenIndiana

2015-07-01 Thread WarGrey Gyoudmon Ju
Okay. It works.
Thank you.

On Tue, Jun 30, 2015 at 7:13 PM, Matthew Flatt  wrote:

> Would using select() instead of poll() avoid the problem? You could try
> a Racket build that uses select() by changing "mzconfig.h" as generated
> by `configure` to not define `HAVE_POLL_SYSCALL`.
>
> The `configure` script's check for poll() could be disabled easily on
> Solaris if using poll() is a bad idea on that platform.
>
> At Tue, 30 Jun 2015 16:30:23 +0800, WarGrey Gyoudmon Ju wrote:
> > Finally I found the root cause is that pollsys is called too frequently.
> > and this problem seems quite normal in Solaris family.
> >
> > I don't think I can solve it on my own,
> > Solaris-specific JVM provides an option `PerfDataSamplingInterval` as a
> > workaround.
> > Meanwhile I have to restart the daemon as long as it is busy in doing
> > nothing worthy.
> >
> > and more, I have no idea if it would be better to use some other event
> > completion frameworks (say, port_create and friends)
> > to take the place of poll(2)/poll(7d).
> >
> >
> > On Thu, Jun 18, 2015 at 10:17 PM, WarGrey Gyoudmon Ju <
> juzhenli...@gmail.com
> > > wrote:
> >
> > > Hello.
> > >
> > > This is in OpenIndiana.
> > > I found the web server does not want to sleep after handling at least
> one
> > > requests.
> > > Mostly, it just load the entire core, sometimes it keeps increasing
> with
> > > handling few requests,
> > >
> > > but there seems one exception,
> > > if the client is net/http-client (rather than curl, w3m or any other
> > > browsers)
> > > then all is well, the server will sleep as expected.
> > >
> > > BTW, it seems that Racket does not run in Solaris as efficient as in
> other
> > > mainstream
> > > systems.
> > >
> > > 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] Are there any BDD testing frameworks for Racket?

2015-07-12 Thread WarGrey Gyoudmon Ju
I just finished my test framework, based on Scribble and RackUnit.
https://github.com/digital-world/DigiGnome
http://gyoudmon.org/~wargrey:DigiGnome

At the beginning, I focused on BDD,
later I noticed that BDD is a thinking patten more than a coding pattern,
and to not lose the purpose of communicating between coder and businessmen,
finally I choose Literate Programming rather than defining sugar syntaxes.

As a normal racket module, its output looks like hspec;
as a scribble module, it also embeds a perl prove-like report.

Also, there are two more test types for TODO and SKIP.

On Mon, Jul 13, 2015 at 1:08 PM, Alexis King  wrote:

> > Short version: I think it's a good idea. I don't know of anything like
> > that, yet. I'm interested in BDD, but not so much a Gherkin style DSL.
>
> Yeah, I currently have no plans to implement something like Gherkin. All I
> care about for the time being is spec-style `describe`, `context`, `it`,
> and similar. I don’t really use Cucumber for much, but it would obviously
> be possible to build a DSL on top of a spec-style framework.
>
> > Out of curiosity, what are you looking to test? If it's an HTTP api,
> I've got a ton of useful testing tools for that that I was just thinking of
> making into a package.
>
> It’s nothing HTTP-related, just some plain old Racket code. I’m really
> just interested in having the ability to write spec-style tests in general.
> That said, I’m sure it would be nice to have that sort of thing in a
> package, anyway, so I’d still be interested to see what you have!
>
> Also, since Sam pointed out on IRC that some people might not know what
> BDD is, I’ll include a brief demonstration of what I’d sort of like to
> build. It’s mostly just a different API for writing tests that tries to be
> a little more declarative. For example, testing the `+` function might look
> like this:
>
> (describe "+"
>   (context "when a single argument is provided"
> (it "is the identity"
>   (expect (+ 1) (to equal? 1))
>   (expect (+ -1) (to equal? -1
>   (context "when multiple arguments are provided"
> (it "adds numbers"
>   (expect (+ 1 2) (to equal? 3))
>   (expect (+ 1 -2) (to equal? -1)
>
> If a test fails, it provides some nicely-formatted information about the
> test and its context. For example, consider adding the following bogus test:
>
> (describe "+"
>   (context "when a single argument is provided"
> (it "is the identity"
>   (expect (+ 1) (to equal? 1))
>   (expect (+ -1) (to equal? 1 ; oops, typo
>   (context "when multiple arguments are provided"
> (it "adds numbers"
>   (expect (+ 1 2) (to equal 3))
>   (expect (+ 1 -2) (to equal -1)))
> (it "returns a positive number"   ; this is just wrong
>   (expect (+ 3 -5) (to be positive?)
>
> That might cause the following output:
>
>   +
>   ├── when a single argument is provided
>   │ ✘ is the identity
>   │
>   └── when multiple arguments are provided
> ✔︎ adds numbers
> ✘ returns a positive number
>
>   Failures:
>
>   1) + is the identity when a single argument is provided
>
>  Expectation: (expect (+ -1) (to equal? 1))
> Expected: 1
>  Got: -1
>
>  ; ./sample-spec.rkt:12:6
>
>   2) + returns a positive number when multiple arguments are provided
>
>  Expectation: (expect (+ 3 -5) (to be positive?))
> Expected: value that satisfies ‘positive?’
>  Got: -2
>
>  ; ./sample-spec.rkt:18:6
>
>   3 examples, 2 failures, 0 pending
>
> The output format and the expectation syntax is entirely theoretical and
> subject to change, but that’s the basic idea. The good news is, I think all
> the basic operations can be defined in terms of existing RackUnit
> constructs, so the only difficulties would be implementing the output
> format and the expectations system. Ideally, though, this would provide
> some more semantic information both in how tests are written and in test
> failure messages.
>
> 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.


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


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


[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,
&session->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 

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  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 
> 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-24 Thread WarGrey Gyoudmon Ju
  
-  lwp# 6 / thread# 6  
-  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 
wrote:

> Okay, thank you Matthew.
>
> On Thu, Sep 17, 2015 at 10:17 PM, Matthew Flatt 
> 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 
>> 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] 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] 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-28 Thread WarGrey Gyoudmon Ju
On Sat, Apr 29, 2017 at 5:21 AM, Daniel Prager 
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-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  wrote:

>
>
> On Sat, Apr 29, 2017 at 5:21 AM, Daniel Prager 
> 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-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] 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] Convert mouse coordinates in mouse-event% to window coordinates? And also for snip%...

2017-05-24 Thread WarGrey Gyoudmon Ju
Hi, yes, this requirement is not as easy as it looks like.
I just listed all the methods that most useful, by reading their docs, you
can easily find your algorithm to compute the correct location.

I  mentioned you snip% does not have its own mouse event object,
 therefore, you cannot obtain the enter and leave event stats of a snip.
Sometimes it works, because your mouse happens to leaving the listbox and
entering the editor-canvas%. Here is my solution:

(define &hover (box #false)) ; the last hovered snip

(define/override (on-event mouse)
  (super on-event mouse)
  (define &editor-x (box (send mouse get-x)))
  (define &editor-y (box (send mouse get-y)))
  (global-to-local &editor-x &editor-y)
  (define maybe-snip (find-snip (unbox &editor-x) (unbox &editor-y)))
  (let ([hovered (unbox &hover)])
(when (and hovered (not (eq? hovered maybe-snip)))
  '(on-leaving))
(set-box! &hover maybe-snip)
(when (and maybe-snip (send mouse moving?) (not (send mouse
get-left-down)))
  '(on-hover


On Thu, May 25, 2017 at 12:59 AM, Erich Rast  wrote:

> Hi,
>
> Thanks a lot for your answer! The methods you mention for A3 do not
> give the right results, though. Here is my current callback with your
> method, where show-info really just opens a window at the x and y
> coordinate:
>
>  (lambda (snip evt dc show?)
>   (and-let* ((admin (send snip get-admin))
>  (editor (send admin get-editor))
>  (editorx (box 0))
>  (editory (box 0))
>  (win (get-top-level-edit-target-window)))
> (send admin get-view x y w h snip)
> (send editor get-snip-location snip editorx editory)
> (send editor local-to-global editorx editory)
> (let*-values (((tx ty) (send win client->screen (inexact->exact
>  (unbox editorx)) (inexact->exact (unbox editory)
>   (displayln (format "position x=~s y=~s" tx ty))
>   (send snip show-info
> (inexact->exact (+ tx (unbox w)))
> (inexact->exact (+ ty (unbox h)))
> show?
>
> In this case, I'd like to have the window left below the snip, but it
> shows up in a completely different place. (The x coordinate seems
> roughly close, but skewed, the y-coordinate is far too small.)
>
> The closest I got to a solution so far is this clumsy callback:
>
> (lambda (snip evt dc show?)
>   (and-let* ((admin (send snip get-admin))
>  (canvas (get-canvas))
>  (editor (send admin get-editor))
>  (editor-canvas (send editor get-canvas))
>  (panel (send editor-canvas get-parent))
>  (p2 (send panel get-parent))
>  (x (box 0))
>  (y (box 0))
>  (w (box 0))
>  (h (box 0))
>  (editorx (box 0))
>  (editory (box 0))
>  (win (get-top-level-edit-target-window)))
> (send admin get-view x y w h snip)
> (send editor get-snip-location snip editorx editory)
> (send editor local-to-global editorx editory)
> (let-values (((tx ty)
>   (send win client->screen
> (inexact->exact (unbox editorx))
> (inexact->exact (unbox editory)
>   (send snip show-info
> (inexact->exact (+ (send p2 get-x) tx (unbox w)))
> (inexact->exact (+ (send panel get-y) ty (unbox h)))
> show?
>
> (Please ignore any unused variables, I've experimented with many
> different approaches.)
>
> This nearly gives the right result, so it seems as if I have to
> traverse the nested hierarchy of controls in order to find the 'right'
> control that doesn't have a 0 x- and y-coordinates because it is just
> locally embedded. This unfortunately means that if I change the layout
> geometry, the approach will fail. Not very good.
>
> In any case, the window location is still off, a little bit too much to
> the left and about the size of the tab panel heading to the top of
> where it ought to be. See the @"Notes":26 test window as a popup for
> the purple snip in the attached screenshot.
>
> Is there any way to fix this or a more general, easier way to get the
> coordinates?
>
> Best,
>
> Erich
>
> p.s. Another, more serious issue is that hovering the mouse over the
> snip and leaving it only works sometimes (e.g. when I hover from the
> listbox directly to the snip) and fails most of the time. But one thing
> at a time.
>
> On Wed, 24 May 2017 07:03:45 +0800
> WarGrey Gyoudmon Ju  wrote:
>
> > Hi Rast
> >
> > the mouse event object of editor% and snip% is always the one passed
> > to the

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 only in non-typed

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] 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] 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] 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] 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] 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] 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] Embedding Rust in Racket

2015-11-09 Thread WarGrey Gyoudmon Ju
Because C side output port is not controlled by (current-output-port) and
(current-error-port) directly, C code always use the default ones.
In theory, one can write a simple wrapper to deal with
(current-output-port).

On Tue, Nov 10, 2015 at 1:45 PM, Ty Coghlan  wrote:

> It works correctly if I run it from the command line using the racket
> command, thanks! It also works if I raco exe it.
>
> Whether or not to add lib to the name of the file seems to be operating
> system specific, or so I understand it. Windows seems to prefer leaving it
> as "embed". Any idea why DrRacket seems to redirect the output?
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and 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] 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] 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.


[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] [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  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: #
> >   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

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

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


[racket-users] [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] [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: #
  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  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 
> 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)).
> > > >
> > > 

[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 
wrote:

> Yes, right. This is why I suggested drdr.
>
> Robby
>
> On Sat, Jan 9, 2016 at 11:38 AM, Sam Tobin-Hochstadt
>  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
> >  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 
> 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.


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


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.


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

2016-02-21 Thread WarGrey Gyoudmon Ju
On Sun, Feb 21, 2016 at 4:13 PM, Asumu Takikawa  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] 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
> > actual: 1
> > exp

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] 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", &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", &a, b, &c);
>
>   // 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] IO in racket is painful

2016-03-22 Thread WarGrey Gyoudmon Ju
On Wed, Mar 23, 2016 at 8:26 AM, WarGrey Gyoudmon Ju 
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.


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


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

2016-04-08 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] [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.


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


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


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] 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] 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 
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
> >  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] 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] 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 :
>
> Right, that did it, thanks!
>
> 2016-08-31 14:19 GMT+02:00 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] 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] 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] 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] 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.


  1   2   >