Re: [racket-users] Are the terms "function" and "procedure" synonymous in Racket?

2019-01-19 Thread George Neuner



And one by our own Jay McCarthy (with Neil Toronto)

https://www.computer.org/cms/Computer.org/ComputingNow/issues/2014/10/mcs2014040080.pdf

--
You received this message because you are subscribed to the Google Groups "Racket 
Users" group.
To unsubscribe from this group and 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 the terms "function" and "procedure" synonymous in Racket?

2019-01-19 Thread George Neuner


On 1/19/2019 10:37 PM, David Storrs wrote:
On Fri, Jan 18, 2019, 6:36 PM George Neuner  wrote:



 witness the legions of newbies every
year who don't understand that computer arithmetic differs from
the math
they were taught in school.


Does it? Bit of a philosophical question, it seems. I mean, so long as 
you stick with integers, if you start with the same numbers and run 
them through the same operations then you will end up with the same 
results regardless of whether you did it on paper or in a computer. 
Things get a little weird once you start going into floating point, 
but I contend that that's a difference in 
implementation/representation, not in math.




As Ellen already mentioned, fixed width integers - although exact values 
- have computational properties that are not shared with mathematical 
integers.  As soon as the computation overflows, all bets are off ... 
any number of mathematical invariants may no longer hold.


The troubles with floating point are caused by the representation, but 
they aren't limited by it.  FP numbers are not simply "limited 
precision" approximations of real numbers, but actually are a fuzzy 
range that only contains the "limited precision" approximation, and you 
don't know where within that range the actual value lies.


FP math bears little resemblance to real math:

 * FP numbers are neither associative nor distributive
 * even simple invariants like (A+B)-B = A or A+A = 2*A may not hold
 * FP numbers don't necessarily have a multiplicative inverse: not all
   A have a B= 1/A such that A*B = 1
 * FP numbers are not continuous:  e.g., B > 0 doesn't mean A+B > A

and there is plenty more.  The so-called BigFloat implementations don't 
change these properties - they simply push them out further away from 
the programmer [who still can be bitten by problems].


There are any number of good references available, but here are a few 
[increasing in technicality] to get you started.


[1] 
http://www.phys.uconn.edu/~rozman/Courses/P2200_15F/downloads/floating-point-guide-2015-10-15.pdf

[2] http://people.ds.cam.ac.uk/nmm1/Arithmetic/index.html
[3] https://www.itu.dk/~sestoft/bachelor/IEEE754_article.pdf


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.


Re: [racket-users] Are the terms "function" and "procedure" synonymous in Racket?

2019-01-19 Thread Ellen Spertus
On Sat, Jan 19, 2019 at 7:37 PM David Storrs  wrote:

>
>
> On Fri, Jan 18, 2019, 6:36 PM George Neuner 
>>
>>  witness the legions of newbies every
>> year who don't understand that computer arithmetic differs from the math
>> they were taught in school.
>>
>
> Does it? Bit of a philosophical question, it seems. I mean, so long as you
> stick with integers, if you start with the same numbers and run them
> through the same operations then you will end up with the same results
> regardless of whether you did it on paper or in a computer. Things get a
> little weird once you start going into floating point, but I contend that
> that's a difference in implementation/representation, not in math.
>

Even integers operations behave differently on computers than in math. Most
programming languages (or implementations) have 32- or 64-bit integers.

ob. xkcd: https://xkcd.com/571/

[image: image.png]

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and 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 the terms "function" and "procedure" synonymous in Racket?

2019-01-19 Thread David Storrs
On Fri, Jan 18, 2019, 6:36 PM George Neuner 
>  witness the legions of newbies every
> year who don't understand that computer arithmetic differs from the math
> they were taught in school.
>

Does it? Bit of a philosophical question, it seems. I mean, so long as you
stick with integers, if you start with the same numbers and run them
through the same operations then you will end up with the same results
regardless of whether you did it on paper or in a computer. Things get a
little weird once you start going into floating point, but I contend that
that's a difference in implementation/representation, not in math.

>

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and 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] OpenGL in build w/ package server

2019-01-19 Thread Matt Jadud
Many thanks, Jay. I can work with that.

On Sat, Jan 19, 2019 at 10:13 AM Jay McCarthy 
wrote:

> This page talks about foreign library on the package build:
>
> https://pkg-build.racket-lang.org/about.html#foreign
>
> It's plausible the GLU is something common enough, we should install
> it by default.
>
> On Sat, Jan 19, 2019 at 3:10 PM Matt Jadud  wrote:
> >
> > Hi all,
> >
> > Is there a way to convince the package server to build packages that
> rely on the OpenGL bindings? Perhaps something in the deps of info.rkt that
> I don't understand?
> >
> > raco setup:   ffi-lib: couldn't open "libGLU.so.1" (libGLU.so.1: cannot
> open shared object file: No such file or directory)
> >
> > Cheers,
> > Matt
> >
> > --
> > You received this message because you are subscribed to the Google
> Groups "Racket Users" group.
> > To unsubscribe from this group and 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   http://jeapostrophe.github.io]=-
> -=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
> -=[ Moses 1:33: And worlds without number have I created; ]=-
>

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

2019-01-19 Thread Stephen De Gabrielle
Tables are pretty cool!

https://www.pyret.org/docs/latest/tables.html


On Fri, 18 Jan 2019 at 22:22,  wrote:

> When it comes to collections and data structures, what would you all like
> to see in Racket2? New APIs? Changes to existing APIs? Whole new paradigms?
> Something else?
>
> I've got my own wishlist and maybe someday I'll implement a few things on
> it as packages, but I'm curious what everyone else thinks. For some
> examples, here's a few things on my list:
>
>
> - Distinct data types for pairs and lists, and more intuitive names for
> the pair APIs (so `pair?` and `list?` would be mutually exclusive
> predicates and you'd make and access pairs with `(pair 1 2)`, `(pair-first
> p)`, and `(pair-second p)`.
>
> - A separation between using lists as homogeneous collections and using
> lists as fixed-size tuples. So there'd be a separate `tuple?` data type
> that's structurally equivalent to a list but meant to be used differently.
> For example, `(list/c number?)` would mean a list of many numbers, but
> `(tuple/c number?)` would mean a tuple of size 1 containing a number.
>
> - Something better and simpler than structs. Throw out mutable fields,
> subtyping, struct type properties, etc. Just the basics: a tuple-like type
> with named fields and a constructor that can enforce invariants on all
> instances.
>
> - Lots more stuff.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Racket Users" group.
> To unsubscribe from this group and 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] OpenGL in build w/ package server

2019-01-19 Thread Jay McCarthy
This page talks about foreign library on the package build:

https://pkg-build.racket-lang.org/about.html#foreign

It's plausible the GLU is something common enough, we should install
it by default.

On Sat, Jan 19, 2019 at 3:10 PM Matt Jadud  wrote:
>
> Hi all,
>
> Is there a way to convince the package server to build packages that rely on 
> the OpenGL bindings? Perhaps something in the deps of info.rkt that I don't 
> understand?
>
> raco setup:   ffi-lib: couldn't open "libGLU.so.1" (libGLU.so.1: cannot open 
> shared object file: No such file or directory)
>
> Cheers,
> Matt
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and 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   http://jeapostrophe.github.io]=-
-=[ Associate ProfessorPLT @ CS @ UMass Lowell ]=-
-=[ Moses 1:33: And worlds without number have I created; ]=-

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and 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] OpenGL in build w/ package server

2019-01-19 Thread Matt Jadud
Hi all,

Is there a way to convince the package server to build packages that rely
on the OpenGL bindings? Perhaps something in the deps of info.rkt that I
don't understand?

raco setup:   ffi-lib: couldn't open "libGLU.so.1" (libGLU.so.1:
cannot open shared object file: No such file or directory)

Cheers,
Matt

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and 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] Examples of #:inv in Redex?

2019-01-19 Thread Robby Findler
The variables from the contract are bound only if they have
underscores in them (because ones without underscores are not
constrained to be the same when they appear in contract positions (or
in define-language)). I've pushed a small clarification of this in the
docs and below is a program that demonstrates an invariant in action.

hth,
Robby

#lang racket/base
(require redex)

(define-language L
  [nat ::= Z (S nat)])

(define-judgment-form L
  #:mode (sum I I O)
  #:contract (sum nat_1 nat_2 nat_3)
  #:inv (≤ nat_3 nat_1)

  [---
   (sum Z nat nat)]

  [(sum nat_1 nat_2 nat_3)
   ---
   (sum (S nat_1) nat_2 (S nat_3))])

(define-judgment-form L
  #:mode (≤ I I)
  #:contract (≤ nat nat)

  [
   (≤ Z nat)]

  [(≤ nat_1 nat_2)
   
   (≤ (S nat_1) (S nat_2))])

(judgment-holds (sum (S (S (S Z)))
 (S (S (S (S Z
 nat)
nat)


On Fri, Jan 18, 2019 at 7:03 PM Joey Eremondi  wrote:
>
> I'm wondering, are there any good examples out there of using #:inv with 
> Redex-judgments? Particularly with asserting that some other judgment holds 
> on the output.
>
> For example, I've got:
>   #:contract (SomeJudgment Gamma tt gv gU)
>   #:inv ,(judgment-holds (SomeOtherJudgment gv gU))
>
> The problem I'm having right now is that, if I unquote gv and gU in the 
> invariant, it says they're unbound variables. But if I quote them, it uses 
> the literal terms (term gv) and (term gU), that is, it's not properly 
> binding/substituting gv and gU when it's evaluating the contract.
>
> If I add a (begin (println (term gv) ... ) to the contract, it prints 'gv, 
> confirming that the substitution isn't happening.
>
> Am I using this wrong? Are there examples of its proper usage, or is this 
> just a mostly-unused feature in Redex?
>
> Thanks for all the Redex help!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Racket Users" group.
> To unsubscribe from this group and 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] Collections and data structures wishlist?

2019-01-19 Thread Jack Rosenthal
On Fri, 18 Jan 2019 at 14:22 -0800, jackhfi...@gmail.com wrote:
> When it comes to collections and data structures, what would you all like
> to see in Racket2? New APIs? Changes to existing APIs? Whole new paradigms?
> Something else?

Maybe you'll need to clarify what Racket2 is? I am not familiar.

> - Distinct data types for pairs and lists, and more intuitive names for the 
> pair APIs (so `pair?` and `list?` would be mutually exclusive predicates 
> and you'd make and access pairs with `(pair 1 2)`, `(pair-first p)`, and 
> `(pair-second p)`.
> 
> - A separation between using lists as homogeneous collections and using 
> lists as fixed-size tuples. So there'd be a separate `tuple?` data type 
> that's structurally equivalent to a list but meant to be used differently. 
> For example, `(list/c number?)` would mean a list of many numbers, but 
> `(tuple/c number?)` would mean a tuple of size 1 containing a number.

While these changes may make the language easier to read (slightly,
easier to discern programmer intent in some cases), as well as slightly
more reliable (harder to write incorrect programs), you'll have to
consider the negative impacts as well.

Programmers would often want a way to accept what was previously
considered just a list, so we might see collection/c (or a similar name)
come to be defined to (or/c list/c tuple/c ...). And, to work with these
collections comes generic operations (collection-first ...). This may be
the paradigm in other languages like Python, but Racket is not Python.
My hunch is that this would make the language harder to write in, and
create potential constraints when it comes to optimization.

Jack

-- 
Jack M. Rosenthal
http://jack.rosenth.al

No, sir... clicking on 'Remember Password' will NOT help you remember
your password.

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


signature.asc
Description: PGP signature


[racket-users] Requiring "introduced identifiers" to be explicitly declared

2019-01-19 Thread Sorawee Porncharoenwase
Is it possible to require "introduced identifiers" to be 
explicitly declared, and error otherwise? For instance:

(define-syntax (swap stx)
  (my-syntax-parse stx
[(_ x y)
 (with-syntax ([(tmp) (generate-temporaries #'(my-tmp))])
   #'(begin
   (define tmp x)
   (set! x y)
   (set! y tmp)))]))

(define a 1)
(define b 2)
(swap a b)
a
b

should output 2 and then 1. But:

(define-syntax (swap stx)
  (my-syntax-parse stx
[(_ x y)
 #'(begin
 (define tmp x)
 (set! x y)
 (set! y tmp))]))

(define a 1)
(define b 2)
(swap a b)
a
b

should error.

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

2019-01-19 Thread jackhfirth
On Friday, January 18, 2019 at 11:50:48 PM UTC-8, Matthias Felleisen wrote:
>
>
> On Jan 18, 2019, at 10:22 PM, jackh...@gmail.com  wrote:
>
>
> - A separation between using lists as homogeneous collections and using 
> lists as fixed-size tuples. So there'd be a separate `tuple?` data type 
> that's structurally equivalent to a list but meant to be used differently. 
> For example, `(list/c number?)` would mean a list of many numbers, but 
> `(tuple/c number?)` would mean a tuple of size 1 containing a number.
>
>
>
> "It is better to have 100 functions operate on one data structure than 10 
> functions on 10 data structures.” 
> http://www.cs.yale.edu/homes/perlis-alan/quotes.html
> "It is better to have 100 transducers operate on one data structure 
> interface than 10 functions on 10 data structures.” Rich Hickey, History of 
> Clojure 
>

100 functions on one data structure is how you end up with unreadable 
function names like list* and cadadr.

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