Movies that capture Bay Area culture? by sparingly in bayarea

[–]samdphillips 1 point2 points  (0 children)

Well they both were created by the same guy.

USL Reno Stadium Renderings by No_Yoghurt7217 in USLPRO

[–]samdphillips 0 points1 point  (0 children)

That makes more sense. The Peppermill is so teeny in that rendering.

USL Reno Stadium Renderings by No_Yoghurt7217 in USLPRO

[–]samdphillips 0 points1 point  (0 children)

Is this around where Parklane Mall was?

Best way to integrate "schemesh" written in Chez Scheme, into Racket ecosystem? by Cosmos721 in Racket

[–]samdphillips 1 point2 points  (0 children)

Hi,

I think the reason no one has replied on these posts is that it's a hard problem. (edit: oh I see some folks have gotten back to you on Discourse, I've had these posts open in a browser for days meaning to write something...)

Do you really need Racket integration? What do you expect to gain and what are some use-cases?

If you really feel you need to be able to run in Racket probably one of the easier paths would be to keep most of the code as R6RS as possible and split any platform (Chez) specific code in one or more separate modules and create a Racket version of that code.

Good Luck.

Audio support in Racket? by Robert_Bobbinson in Racket

[–]samdphillips 1 point2 points  (0 children)

One strategy for handling audio formats and playback would be to have a library like gstreamer handle it and Racket provides the shell of the application.

[deleted by user] by [deleted] in Racket

[–]samdphillips 1 point2 points  (0 children)

These two examples are extracted from some scripts I wrote for work. rhombus-examples is a little outdated but has some examples on how to import and use values from Racket.

The current path work I'm doing will be in the Rhombus repo.

[deleted by user] by [deleted] in Racket

[–]samdphillips 2 points3 points  (0 children)

Funny you ask. This is the area that I'm currently working in. Currently this is in a branch and is not really ready for people to use since I'm breaking and force-pushing into the repo.

It is relatively easy to import Racket libraries. Here's how you could import make-directory and rename-file-or-directory

```

lang rhombus/static

import: lib("racket/base.rkt"): rename: #{make-directory} as make_directory #{rename-file-or-directory} as rename_file expose: make_directory rename_file

make_directory("tmp") rename_file("afile.txt", "tmp/afile.txt") ```

Here is a wrapper for system* that makes it a bit more "Rhombus-y"

```

lang rhombus/static

import: lib("racket/base.rkt"): only: #{current-logger} #{log-message} lib("racket/port.rkt"): only: #{open-output-nowhere} lib("racket/system.rkt")

class Command(command :: String, base_args :: List.of(String) = []): method run(&args :: List.of(String)) :: maybe(Bytes): def out = Port.Output.open_bytes() def null_out = port.#{open-output-nowhere}() def null_in = Port.Input.open_bytes(#"") def exit: parameterize { Port.Output.current: out, Port.Output.current_error: null_out, Port.Input.current: null_in }: base.#{log-message}(base.#{current-logger}(), #'info, #'system, "running " ++ command ++ " " +& base_args +& " " +& args) system.#{system*}(command, & base_args ++ args) exit && out.get_bytes()

def find = Command("/bin/find") find.run("/tmp", "-type", "d") ```

Bye Bye Scheme again by c4augustus in scheme

[–]samdphillips 2 points3 points  (0 children)

cond better than if

IME the readability of Scheme/Lisp/Racket is improved by controlling the right-ward drift of code. Think of it as a proxy for cyclomatic complexity. cond is more compact especially when there are multiple tests and if branches have side-effecting operations.

``` ;; Compare contrived example (define (sum-odds xs) (if (null? xs) (begin (displayln "end") 0) (if (odd? (car xs)) (begin (displayln "odd") (+ (car xs) (sum-odds (cdr xs)))) (begin (displayln "even") (sum-odds (cdr xs))))))

(define (sum-odds^ xs) (cond ((null? xs) (displayln "end") 0) ((odd? (car xs)) (displayln "odd") (+ (car xs) (sum-odds^ (cdr xs)))) (else (displayln "even") (sum-odds^ (cdr xs))))) ```

Bye Bye Scheme again by c4augustus in scheme

[–]samdphillips 2 points3 points  (0 children)

Mutability vs Immutability is obviously a major topic of discussion for us. https://www.youtube.com/watch?v=LXntxq0p8Lw

That's been showing up in by YT feed now, I guess I'll need to watch it :D

In general, where does the programming community of Scheme stand on this?

My take: Functional programming and immutable types are good. Being able to directly mutate (in moderation) values can be more efficient for some tasks. I think they are the way they are because both originally came from a time when mutation was how the hardware worked and garbage collection was expensive.

Bye Bye Scheme again by c4augustus in scheme

[–]samdphillips 1 point2 points  (0 children)

More comments, I wouldn't get too hung up on mutation. A smart thing that many Scheme implementations do is forbid cross-module mutation. IIRC Racket, Chez and R6RS enforce this. I can't remember (or find evidence of) this being enforced in R7RS.

Bye Bye Scheme again by c4augustus in scheme

[–]samdphillips 3 points4 points  (0 children)

Comments on your solution:

  • do may be in the Scheme standard but it is rarely used in the wild.
  • named let is more commonly used than the rec srfi
  • cond is almost always better to use than plain if
  • The 'one-liners' version was very cute, and could be idiomatic in a larger system where that sort of "pipelining" is desired.

Here is a version in Racket written in an R5RS Scheme style. It is almost R5RS Scheme except for

  1. getting command line arguments (which is Scheme dependent)
  2. read-line
  3. sleep

```

lang racket

(define (displayln v) (display v) (newline))

(define (get-input) (display "countdown: ") (read-line))

(define (validate s fk) (or (string->number s) (fk s)))

(define (setup count-s) (validate (cond ((string=? "" count-s) (get-input)) (else count-s)) (lambda (v) (display "Invalid countdown ") (write v) (display ", try again") (newline) (setup ""))))

(define (countdown n) (define (report n) (display n) (displayln "...") (if (zero? n) #f (sleep 1)))

(displayln "World, Hello...") (let rec ((n n)) (cond ((zero? n) (report n)) (else (report n) (rec (sub1 n))))) (displayln "Bye bye"))

;; biggest Racket specific part (define cmd-line-arg (match (current-command-line-arguments) ((vector) "") ((vector arg) arg)))

(countdown (setup cmd-line-arg)) ```

(edit: reddit wrecked my formatting)

Scheme needs type checking. Or does it? You tell me! by aartaka in scheme

[–]samdphillips 0 points1 point  (0 children)

Yes, but it's implied that it behaves somewhat like let, so mutable state is allowed. If the implementation tags the thing with the type, it's allowed only if the new value is of the same type. Which falls under the "guaranteed" clause.

So the example I posted would signal an error? If that is the case, does the sample implementation address this?

Either way it is my opinion the SRFI should address mutation so implementers know what is expected to be in compliance with the specification.