benjamin.clos
2019-2-19 11:14:15

oh, awesome, that seems to be exactly what I was looking for. Thanks!


lspector
2019-2-19 11:56:41

Thank you @philip.mcgrath for your patient and thorough explanation. I believe that the server I use is running Apache. With Clojurescript, I can compile something and move the resulting folder to the server, and then anyone can point a browser to the index.html file in the folder on the server and it runs. Long ago I did something similar using a combination of C++ and Common Lisp. Do I understand correctly that nothing like this is possible using Racket? If so, then I guess I would indeed need to run a command on the server to start up the Racket part of the server, and set something up so that that it runs automatically when the server is rebooted, or get my sysadmin to do those things. If this is right, then is there a concise description of the needed command/setup that can be conveyed to someone who doesn’t already have much knowledge beyond Racket? I ask both for my own projects and for my teaching of new programmers, for whom I gather Racket is intended to serve as a good environment. If the student has made a thing that they want to share, by making it run on the web, and they have a public_html directory on a university server, what is the magic to make the thing run online, where their friends and family can check it out?


d_run
2019-2-19 13:16:28

Compiling ClojureScript makes a JS file that you can include into an html file via script tags, in your case index.html. When you were running C++/Common Lisp was this via cgi bin perchance?


d_run
2019-2-19 13:17:35

Racket does have bindings for CGI (https://docs.racket-lang.org/net/cgi.html) which is a real old school way of generating dynamic web content


d_run
2019-2-19 13:20:09

(Also, if you want to share smaller one-off scripts online, there is http://pasterack.org/)


lspector
2019-2-19 13:21:46

Yeah, my C++/Common Lisp approach did involve cgi. I don’t remember the details though. Do you think this is a reasonable approach for the need I’ve outlined above?


lspector
2019-2-19 13:23:23

The pasterack thing does look like it could be helpful for some of my purposes, albeit awkward and limited, I’m guessing.


d_run
2019-2-19 13:23:42

I think if you want to get something simple up, and your current server environment supports CGI then it might be a good bet to experiment with. Would ask your admin if CGI is available.


lspector
2019-2-19 13:26:48

Thanks. Do you know of simple instructions/examples that show how to take a simple thing that runs locally and use the CGI approach to put it in a public_html directory, assuming that CGI is available?


d_run
2019-2-19 13:28:59

Unfortunately I don’t. I’ve never really used CGI. My understanding from way back when I used to work with shared hosts was that there was usually a /cgi_bin directory to put scripts in.


lspector
2019-2-19 14:04:48

Got it. I guess the more reasonable way forward would be to run the Racket server command on the server, and set things up so that happens automatically when the server is rebooted. That being the case, is there documentation for doing this that a new Racket programmer could follow? Based on what I see of the Racket community’s interest in new programmers (who will be motivated by being able to share their creations), I would think that this would be appreciated by people other than me (and me! :slightly_smiling_face:)


philip.mcgrath
2019-2-19 14:05:15

I actually used Racket for CGI programming before I learned the web-server library. The good part about CGI programming in Racket is that you’re doing it in Racket. The bad part about it is that you’re doing CGI programming and you have to live with all of its limitations, without the innovations of the web-server library for managing interactive programs in particular. More practically, using CGI still means you need to have Racket installed on your server, including all of the packages you’re using. (You could also compile your program into a stand-alone executable and install that on your server, but that doesn’t get you much farther.) If your server administrator is willing to do that, then putting #!/usr/bin/env racket on the first line of your script (before the #lang line) and making it executable with chmod +x will make it work the way CGI expects, though where you have to put it depends on how Apache is configured on your specific server. But, if your server administrator is willing to do that, they’re most of the way toward letting you run a Racket web-server program on a local port, which is much better in most circumstances.


lspector
2019-2-19 14:07:20

Thanks for the additional detail! This reinforces my impression that CGI isn’t really the way to go, and running a Racket web-server program on a local port is better… So it’d be great to have instructions for that that could be followed by someone who doesn’t know much more than how to write a simple Racket program.


philip.mcgrath
2019-2-19 14:09:45

@lspector This is the systemd unit file I use to automatically run the Racket web server for https://digitalricoeur.org [Unit] Description=Digital Ricoeur portal web server [Service] User=ricoeurd Group=ricoeurd AmbientCapabilities=CAP_NET_BIND_SERVICE WorkingDirectory=/home/ubuntu/ricoeur-portal/ ExecStart=/usr/local/bin/ricoeur-portal --production [Install] WantedBy=multi-user.target


philip.mcgrath
2019-2-19 14:10:59

lspector
2019-2-19 14:14:30

Interesting! Not least because of the Ricoeur I read back in my philosophy major days :slightly_smiling_face:. I think I would have to take a big step back, though, to figure out what to do with a systemd file and how/where to use the raco material to which you linked.


philip.mcgrath
2019-2-19 14:27:41

There is also some basic guidance on running behind Apache in the web-server documentation: https://docs.racket-lang.org/web-server-internal/Troubleshooting_and_Tips.html


lspector
2019-2-19 14:43:25

Thanks. For the moment that’s going in my collection of tabs with stuff I don’t yet understand, but I will try to look back at all of this and see if I can figure out how to use it.


abbyrjones72
2019-2-19 18:38:59

I watched William Byrd’s lecture on interpreters in LISP. Very informative. I lost complete comprehension about 60% of the way through, but was impressed I made it that far. I had no idea LISP was so powerful.


diego
2019-2-19 19:14:20

abbyrjones72
2019-2-19 19:16:41

yep!


diego
2019-2-19 20:51:44

Thanks for the recommendation, I’ll watch it when I have some time.


contact
2019-2-19 21:52:30

Hi! How to get the name of a procedure? For example: #<procedure:number?> -> “number?” thx!


contact
2019-2-19 21:54:28

@benjamin.clos You may look at the threading package. (require threading) ... (define (lisp input) (~&gt; input success ((lift check_input) _) ((lift check_operation_code) _) ((lift check_arguments_length) _) ((lift check_arguments_types) _) ((lift apply_operation) _))) The ~&gt; is the threading macro that kind of works like the \|&gt; elixir operator.


samth
2019-2-19 21:57:30

@contact you want object-name


contact
2019-2-19 21:58:11

thank you !


benjamin.clos
2019-2-19 23:48:08

ah yeah, that was the one recommended above, it looked perfect, but I appreciate you double checking


thegobinath
2019-2-20 04:28:04

@thegobinath has joined the channel


abbyrjones72
2019-2-20 05:16:15

It’s really fun and very mind-blowing.


abbyrjones72
2019-2-20 07:05:56

I am liking LISP/Racket so much I am making a blog about my learning journey lol.


hey.calmdown
2019-2-20 07:14:53

@hey.calmdown has joined the channel


hey.calmdown
2019-2-20 07:19:30

A very dumb question from a very newbie here (~&gt; '(1 2 3) (map writeln _)) ;;; 1 ;;; 2 ;;; 3 ;;; '(#&lt;void&gt; #&lt;void&gt; #&lt;void&gt;) Where do the #&lt;void&gt;s came from?


sorawee
2019-2-20 07:25:38

writeln has a side effect, which is to write the data to the current output port (e.g., stdout), but the output of writeln itself is (void)


sorawee
2019-2-20 07:27:48

Perhaps what you want is (~&gt; '(1 2 3) (for-each writeln _))


hey.calmdown
2019-2-20 07:29:32

oh!


sorawee
2019-2-20 07:29:33

Unlike map, which will collect outputs from the function together to create a list, for-each discards them. Hence, for-each is useful when the function is primarily invoked for side-effect


hey.calmdown
2019-2-20 07:29:37

got it


hey.calmdown
2019-2-20 07:29:47

:pray:


hey.calmdown
2019-2-20 07:30:11

works like a charm!


mark.warren
2019-2-20 07:45:37

I believe writeln returns void


mark.warren
2019-2-20 07:46:55

@hey.calmdown So the return value of the map is a list of the void return values from doing each writeln.