mark
2018-10-20 08:44:41

@mark has joined the channel


mark
2018-10-20 08:57:50

So, DrRacket isn’t working under Mojave. 7.0 just silently doesn’t launch, nightly crashes with Library not loaded: @executable_path/../../../lib/Racket.framework/Versions/7.1.0.1_3m/Racket


mark
2018-10-20 08:59:35

It does launch from commandline drracket


andre
2018-10-20 12:27:06

hi friends, as a little project to fiddle more with Racket I decided to port my personal site to it but I am kinda torn between using frog or pollen. Both appear to be good solutions even though on one side Frog might be more appropriated since my site has a blog, and on the other hand, I love how you can build your own commands/tags with Pollen and can see myself using that a lot. Maybe the same thing is possible using scribble sources with frog. Sorry, I am new at this and wonder if some one here could share a quick comment on choosing one or the other. I know this is subjective and I am not looking to spur some form of competition, just looking for advise from more seasoned developers. Thanks.


pocmatos
2018-10-20 12:48:57

@andre Someone might say otherwise here but go Frog. It was built specifically for what you need. Pollen is great, but as a book writing/publishing platform. True, people have used it for webpages/blogging but that’s due to the dedication of the Pollen followers. It doesn’t mean you should start there.


andre
2018-10-20 12:56:19

@pocmatos thanks a lot for the advise. At the moment, I am indeed playing with Frog, trying to get a feel for it. Found some little bugs on how it assembles paths for the RSS/Atom for example, will send a PR. I think Frog might be able to get me up to speed faster specially because as far as I can see, to have collections such as a blog post collection, I’d need to roll my own collection code with Pollen, and I am keen to get all this running today (famous last words).


steveh2009
2018-10-20 14:10:14

I’m thinking of implementing a Racket library to interface to Interactive Brokers API (trading interface). It’s been done in many languages except scheme or lisp (that I can find publicly). The very basic first step is to open up a client TCP connection and parse the incoming byte stream into integers, reals and strings where the delimiters between them is the NUL character. Is there a common best practice in Racket to tie an incoming socket port to a callback function, put it on its own thread, read data when available, otherwise block on the read? OR do I need to setup polling if I cannot block on no data available? (Racket newbie here, but long-time programmer, enjoying this new adventure…thanks!)


andreiformiga
2018-10-20 14:52:04

@andre I don’t think it’s too hard to create a blog/site using Pollen, but it’s true it’s faster with Frog


greg
2018-10-20 15:15:09

@steveh2009 Have you seen “More: Systems Programming with Racket” https://docs.racket-lang.org/more/index.html ? The example is (a) HTTP (b) server, whereas you’re doing (a) non-HTTP (b) client. Even so, there are concepts and example code about using TCP and threads you might find useful.

Short answer to your question: Yes it’s fine/normal to “loop”/block reading from a TCP port. That could be your program’s default/main thread. Or you could do it from another thread, which could communicate to the main thread using something like channels. Or whatever. Depends on context of what your program does.


greg
2018-10-20 15:20:15

Hmm OK scanning that tutorial again, it’s more N/A to what you’re doing, than I remembered. I guess the main point is, you can connect as a TCP client, and you get a Racket port which you can read from like any other port. It may block, but that’s OK. Usually it’s not worth doinking around with “non-blocking I/O” in Racket. Instead, just make a thread, let it block. Racket threads are lightweight (“green”) and Racket has great concurrency primitives like channels and events you can sync on.


andre
2018-10-20 15:22:20

thanks @andreiformiga, going with Frog :slightly_smiling_face:


andreiformiga
2018-10-20 15:24:47

@andre simple site (kinda blog-like) done with pollen: http://andreiformiga.com/retrof/


paul
2018-10-20 17:05:42

What is the convention concerning symbols that start with #% ? It appears that they name low-level procedures.


samth
2018-10-20 17:25:37

@paul few or none of them are procedures, but they’re used for a couple things


samth
2018-10-20 17:26:12
  1. the names of modules that are part of the implementation but are not intended for external use (such as '#%kernel)

samth
2018-10-20 17:26:39
  1. the names of forms implicitly added to the program, such as #%app

samth
2018-10-20 17:27:24

sometimes other low-level things that don’t fit those conventions also use the prefix, but those are the main uses


paul
2018-10-20 17:27:42

I would like to propose a new string escape sequence:

\; comment <newline> whitespace

This escape sequence ignores the rest of the line, the <newline>, and all leading whitespace on the next line. This is useful for commenting long strings (e.g., complex regular expressions) and also for aligning a string continuation line with the beginning of the string on the previous line (which \&lt;newline&gt; does not do).

Here is an example in an assembler I wrote in Hearsay, where / is equivalent to the proposed \;. It also uses \#, which I will propose next.

  ~*S __                                        / Location.
  ~*S __                                        / Object code.
  ~*S ~S __                                     / Value, relocatable indicator.
  ~*S                                           / Beware indicator.
  ~\=line_number_digits;-rS                     / Line number.
  ~S                                            / Source indicator.
  ~S _                                          / Expanded &gt;.
  ~*S                                           / Source line.
  \n";

samth
2018-10-20 17:35:32

@paul that looks like something that could be done with the @ reader pretty easily, right?


paul
2018-10-20 17:35:52

I would like to propose a second new string escape sequence:

\#

This escape sequence causes the string reader to ignore whitespace in the string. This is useful when the string is complex and inserting whitespace between various parts of it can aid readability (see example above). To obtain a space in the string, use an underscore. This requires the addition of the \_ escape sequence to obtain an underscore when in ignore-whitespace mode. This is particularly nice for making complex regular expressions readable.


soegaard2
2018-10-20 17:38:06

Take a look at @. It would be easy to write a ignore and then you can write @ignore{the text with whitespace ignored}


paul
2018-10-20 17:39:15

@samth I am reading section 1.3, “The Reader.” I have not come across the @ reader yet, though I’ve certainly seen examples. Do I find it in the Scribble documentation?




paul
2018-10-20 17:55:54

@soegaard2 Thanks for those links. I’ll add @ expressions to my ever-growing list of things to read. Seems to me that escape sequences are a fundamental part of reading strings and belong at that level of the language. But I’ve been using them for so long that I may be too rigid.


soegaard2
2018-10-20 17:57:06

I have begun using at-expressions to write html (before I used s-expressions).


soegaard2
2018-10-20 17:58:56

I guess I am trying to say, that at-expressions grow on you - but they take some time to get used to.


paul
2018-10-20 18:11:53

Oh, I’m enjoying at-expressions in Scribble while working on the documentation. They are great. But I think to obtain the features of those proposed escape sequences would require some clunky expressions that would decrease readability rather than increase it.

Full disclosure requires that I admit I’ve always been a fan of escape sequences. Then again, I’ve also used ifs and loops in format() control strings, for which I have been severely chastised by my C buddies.


samth
2018-10-20 18:15:23

You could write basically (define x @f{ ~*S __ / Location. ~*S __ / Object code. ~*S ~S __ / Value, relocatable indicator. ~*S / Beware indicator. ~\=line_number_digits;-rS / Line number. ~S / Source indicator. ~S _ / Expanded &gt;. ~*S / Source line. \n"; })


samth
2018-10-20 18:15:32

with an appropriate definition of f


paul
2018-10-20 18:30:55

That’s not bad at all. It’s rather Scribble-like. Obviously, I have a lot to learn.


paul
2018-10-20 23:39:39

@samth said

>2. the names of forms implicitly added to the program, such as #%app

How do I tell from the documentation on #%app that it is not a procedure? It’s clear if it’s a “special form,” such as if.


greg
2018-10-20 23:53:54

@paul https://docs.racket-lang.org/reference/application.html In Racket docs, look at the right side of the “blue box”. Typically it says either “procedure’ or "syntax”. In this case, it says “syntax”. Also, section 3.7 is part of section 3 which is called “Syntactic Forms”.


leif
2018-10-21 01:20:03

Does anyone know if there is a way in the racket ffi to specify a ctype of _string, but also that it should be given to the gc to handle?


leif
2018-10-21 01:20:09

@mflatt ^ ?


mflatt
2018-10-21 01:29:47

Sorry, I don’t understand the question. Is _string an argument, return, or something else? What do you mean by “given to the gc to handle”?


leif
2018-10-21 01:42:11

Basically, I have a C function that calls a Racket callback giving it a char*. (I could also have it pass a char** if that would be better)


leif
2018-10-21 01:42:54

Once it gives it to the Racket callback, the C function no longer owns the string, meaning that the Racket vm needs to free it, either manually or via the gc (or something else).


leif
2018-10-21 01:42:57

Is that a bit clearer?


mflatt
2018-10-21 01:46:09

It sounds like _string as the callback argument is what you want. The C data must be copied, because char* isn’t a Racket string; it will be UTF–8-decoded to a GC-managed Racket string.


leif
2018-10-21 01:53:39

Okay, and in that case the C function will need to dealloc the string?


leif
2018-10-21 01:53:44

err.. char*.


leif
2018-10-21 01:53:48

(Because now there’s two copies)


mflatt
2018-10-21 01:54:26

The snapshot builds are still not signed, so the OS doesn’t trust them, and that’s the root of the problem.

You can make it work by dragging the DrRacket executable out of place (Command-drag if it’s in the “Applications” folder) and then drag it back. Really. Moving the application that way counts as a signal to the OS that you trust the application.


mflatt
2018-10-21 01:56:15

Oh, I missed that you need to delete the argument. I think you need to make the callback accept a _bytes, use bytes-&gt;string/utf-8 to copy/convert, and then free the _bytes argument. There’s not a predefined ctype (as far as I remember) that implements that combination, but you could make one.


leif
2018-10-21 01:57:05

Eh, I can rewrite the C function to delete it if _string makes a copy of the char*.


leif
2018-10-21 01:57:30

(Although in that case it seems like its just a matter of just doing the same thing on the C or Racket side.)


leif
2018-10-21 01:57:32

Anyway, thanks.


paul
2018-10-21 02:37:20

@greg Ha! I thought that just meant it was the syntax for something. Also, I’m not sure why apply can’t be a procedure, but that’s a lesson for another day.


lexi.lambda
2018-10-21 02:39:02

apply is a procedure; the blue box says “procedure” in the corner.


greg
2018-10-21 03:46:41

By the way, I don’t think Racket really uses the phrase “special form”? For instance it hardly appears at all in the main repo including .scrbls: https://github.com/racket/racket/search?p=2&amp;q=%22special+form%22&amp;unscoped_q=%22special+form%22


greg
2018-10-21 03:49:47

@paul I think in Racket we’d talk about “syntax” — maybe “primitive syntax” if it mattered that it were built into Racket. But I’m not sure and probably someone will correct me. I don’t mean to be nit-picky but it sounded like you were working on docs and wanted very specific definitions for things. ¯_(ツ)_/¯


greg
2018-10-21 03:51:39

Oh. And here “syntax” ~= “macros”.


greg
2018-10-21 03:51:53

Words are hard.