I'm trying to get familiar with Rhombus by programming fizz-buzz. I'm having trouble importing libraries from Racket. The following works, but I'd like to not have to type base. in front of each function call. I tried the open modifier after the import but that didn't work.
#lang rhombus
import:
lib("racket/base.rkt")
for (i in 1..=100):
match base.gcd(i, 15)
| 15: base.displayln("fizzbuzz")
| 3: base.displayln("fizz")
| 5: base.displayln("buzz")
| _: base.displayln(i)
For this program specifically, you shouldn’t need imports at all.
#lang rhombus/static
for (i in 1..=100):
match math.gcd(i, 15)
| 15: println("fizzbuzz")
| 3: println("fizz")
| 5: println("buzz")
| _: println(i)
In general, imports in Rhombus should be prefixed or selectively exposed. Only some libraries are intentionally designed to be opened, like rhombus/rx or rhombus/thread, and they are documented as so, without an import prefix. (The documentation convention can be found here.)