kellysmith12.21
2020-11-21 11:09:45

This is probably an odd question: is there a way to make a function contract that checks a parameter at the time of function call? I’m guessing that some kind of chaperone is needed?


tosxychor
2020-11-21 12:39:13

@tosxychor has joined the channel


samth
2020-11-21 14:45:45

See #:pre in ->i


badkins
2020-11-21 20:41:08

To clarify, I was referring to the README.md in the aforementioned fork, not the main frog repo.


badkins
2020-11-21 20:45:44

@greg thanks for your efforts on Frog. I spent a few hours moving some old blog posts into it, and I think it will do nicely for what I need. Unless I stumble into some showstopper (highly unlikely), I expect I’ll move my main blog over to it. I noticed a comment (maybe on github?) about a forum, but what do you think about simply having a #frog channel in this Slack for Frog users to communicate? That seems pretty low friction to me.


arjunubc
2020-11-21 22:30:13

@arjunubc has joined the channel


greg
2020-11-21 23:49:21

Thanks for clarifying, but I did understand you were talking about the fork’s readme. I was just reminiscing.


greg
2020-11-21 23:50:07

I don’t have any thoughts about a #frog channel here. Probably I wouldn’t monitor it but if other folks find it useful that’s great.


greg
2020-11-21 23:50:58

The current “app treadmill” I’ve been on for some years now is Racket Mode. There’s still a lot to do, with that, and that’s about the limit of my focus lately.


matthew.smith16
2020-11-22 00:26:27

@matthew.smith16 has joined the channel


matthew.smith16
2020-11-22 00:44:28

Hi, so I am working on adding some functionality to a Racket package. I am trying to add a function to package “X”, a function such as (define (myBasicTestFunction) (printf "Hello from Package X")) My question is after I have updated the source file, how to I then build it so that the changes are “live”? So if I ran >racket myTestProg.rkt Which looks like #lang racket (require X) (myBasicTestFunction)


sorawee
2020-11-22 00:51:30

how did you install “X”? And where is the file that you edited?


matthew.smith16
2020-11-22 01:16:19

X is any arbitrary package that comes with Racket under share/pkgs and the file is any source file in said package


matthew.smith16
2020-11-22 01:23:18

Say that package X is sgl under share/pkgs/sgl and the file was sgl.rkt


matthew.smith16
2020-11-22 01:25:16

so at the bottom of sgl.rkt I added ... (define (myBasicTestFunction) (printf "Hello from Package X"))


matthew.smith16
2020-11-22 01:26:29

and now myTestProg.rkt would look like #lang racket (require sgl) (myBasicTestFunction)


matthew.smith16
2020-11-22 01:32:12

so if I run >racket myTestProg.rkt it outputs >racket myTestProg.rkt myTestProg.rkt:3:1 myBasicTestFunction: unbound identifier in: myBasicTestFunction location...: myTestProg.rkt:3:1


matthew.smith16
2020-11-22 01:32:59

How do I rebuild the package so that my changes are “live”?


sorawee
2020-11-22 01:39:40

raco setup --pkgs sgl might work, but more importantly, you should never edit any file in share/pkgs. Instead, run raco pkg update --clone sgl at your working directory to create a copy of sgl that you can edit.


matthew.smith16
2020-11-22 01:41:18

gonna test and sign-into slack from the vm I am working in


matthew.smith16
2020-11-22 01:57:45

ok so I know what you are saying about not editing share/pkgs, I read that in the documentation, I do run into problems when running raco pkg update --clone sgl however. >raco pkg update --clone sgl Inferred package name from given `--clone' path package: sgl given path: sgl Inferred package scope: installation raco pkg update: package is not currently installed from a repository package: sgl current installation: (catalog sgl)


matthew.smith16
2020-11-22 02:01:15

I can just use git to clone the repo and then “point” raco to the local copy right?


sorawee
2020-11-22 02:05:41

It’s likely that you will get an installation conflict if you just use git to clone the repo fresh.


sorawee
2020-11-22 02:07:52

I installed Racket from source, which might explain why raco pkg update --clone sgl works for me and not for you. I don’t know what’s the right solution for you though.

Though this paragraph:

> This same approach will generally work if you’re starting from a distribution installer instead of the checkout of the Racket sources from the main Git repository. from https://docs.racket-lang.org/racket-build-guide/contribute.html

suggests that it should work…


matthew.smith16
2020-11-22 02:11:46

I built racket from source also…. I downloaded it from https://download.racket-lang.org/ and selected Unix-Source + built packages and then ran mkdir build cd build ../configure make make install


sorawee
2020-11-22 02:28:16

Oh, by built from source, I meant clone Racket from GitHub.

If I were you, I will go with a different route:

  • Download Minimal Racket from https://download.racket-lang.org/ (which does not come with sgl).
  • git clone <https://github.com/racket/sgl.git>
  • cd sgl
  • /path/to/minimal-racket/bin/raco pkg install

matthew.smith16
2020-11-22 02:29:47

Ok I will try that


matthew.smith16
2020-11-22 02:30:37

does make clean remove the current installation of racket?


sorawee
2020-11-22 02:31:26

I don’t know.. I have never done that.


matthew.smith16
2020-11-22 02:32:09

ok I just didn’t want to have to roll back the VM that far back


matthew.smith16
2020-11-22 02:37:55

so should I download Source + built packages or just Source?


sorawee
2020-11-22 02:40:28

Oh, there’s no need to download source


sorawee
2020-11-22 02:40:52

Well, depends on what platform you are in.


sorawee
2020-11-22 02:41:07

For example, I’m using Mac OS, so I just download dmg installer


sorawee
2020-11-22 02:42:04

IIRC Linux has a .sh installer.


sorawee
2020-11-22 02:42:29

Note that this should be minimal Racket, not full Racket.


sorawee
2020-11-22 02:42:36

Good luck, I gotta go now.


matthew.smith16
2020-11-22 02:42:44

yeah I got it


matthew.smith16
2020-11-22 02:42:51

thanks for your help


matthew.smith16
2020-11-22 05:23:32

So I have downloaded and installed minimal racket, cloned the package sgl, and installed it using raco pkg install. I can see it via raco pkg show which outputs Installation-wide: Package Checksum Source racket-lib 28d0cbe906278e8dc6549010f0f422c5bcde25f4 catalog racket-lib User-specific for installation "7.9": Package Checksum Source sgl link /home/mint/sgl [115 auto-installed packages not shown] anytime I make a change to a source file in the sgl directory i.e adding a basic function to sgl.rkt such as (define (myFunction) (printf "Hello from sgl")) I have been using raco setup --pkgs sgl to compile/build/etc the package. However, racket does not seem to reflect the changes that I have made to the source file. As demonstrated from so: $ racket Welcome to Racket v7.9 [bc]. &gt; (require sgl) &gt; (myFunction) ; myFunction: undefined; ; cannot reference an identifier before its definition ; in module: top-level ; [,bt for context] &gt; How do I compile or build the source code that then is reflected in the actual racket runtime?


sorawee
2020-11-22 05:25:36

Did you provide myFunction?


sorawee
2020-11-22 05:26:48

And just to make sure we are on the same page, the racket executable starts the minimal Racket that you just downloaded, correct?


matthew.smith16
2020-11-22 05:46:08
  1. What do you mean by provide?
  2. It is the only racket that is currently installed on the system so yes…

matthew.smith16
2020-11-22 05:46:39

Sorry for the delayed responses I am making a pizza


sorawee
2020-11-22 06:07:42

sorawee
2020-11-22 06:09:10

If you change the code to:

#lang scheme/base (require (prefix-in gl- "sgl.rkt")) (provide (all-from-out "sgl.rkt") my-function) (define (my-function) (displayln "Hello from sgl")) Then you should be able to use my-function when you (require sgl).


matthew.smith16
2020-11-22 06:27:34

ok I will test


matthew.smith16
2020-11-22 06:32:06

so yeah that works!


matthew.smith16
2020-11-22 06:32:13

Welcome to Racket v7.9 [bc]. &gt; (require sgl) &gt; (my-function) Hello from sgl &gt;


matthew.smith16
2020-11-22 06:33:38

Do you perhaps know why that works from main.rkt and not from sgl.rkt?


sorawee
2020-11-22 07:01:47

The file main.rkt prefixed all exported symbols from sgl.rkt with gl-


sorawee
2020-11-22 07:02:02

So try gl-myFunction?


sorawee
2020-11-22 07:03:45

But note that you need to provide from sgl.rkt too.


sorawee
2020-11-22 07:04:25

Alternatively, when you require, you should reference sgl.rkt via (require sgl/sgl)


sorawee
2020-11-22 07:04:44

For the latter, you don’t need to prefix symbols with gl-


matthew.smith16
2020-11-22 07:15:05

I was reading about the prefix stuff but adding the function (define (my-function) (displayln "Hello from sgl")) to sgl.rkt and then calling it from racket still was not available even when (requiring sgl/sgl) Welcome to Racket v7.9 [bc]. &gt; (require sgl/sgl) &gt; (my-function) ; my-function: undefined; ; cannot reference an identifier before its definition ; in module: top-level ; [,bt for context] &gt; (gl-my-function) ; gl-my-function: undefined; ; cannot reference an identifier before its definition ; in module: top-level ; [,bt for context] &gt;


matthew.smith16
2020-11-22 07:20:07

ok


matthew.smith16
2020-11-22 07:20:14

I found out why


matthew.smith16
2020-11-22 07:22:05

the signature inside of sgl.rkt needs to look like so (provide my-function) (define (my-function) (displayln "Hello from sgl")) and the calling site need to be like so (require sgl) (gl-my-function) Hello from sgl


matthew.smith16
2020-11-22 07:23:33

Thank you for all your help I feel much better about the whole ordeal