
Another surprise with regards to define-generics
… it seems I can’t provide partial fallback methods. If I provide one, I need to provide them all. Although it makes sense to be able to provide some partial implementations. For example, imagine I have: (define-generics symbolics
(find-symbols symbolics) ;; returns list of all symbols
(any-symbols? symbolics) ;; return true if there are any symbols
)

It makes sense to provide a default definition of any-symbols?
which defaults to (define (any-symbols? s) (not (null? (find-symbols s))))
and yet leave to the user the task of specifying find-symbols
, however racket either allows all fallbacks defined or no fallbacks defined. Is anyone aware why this design decision was taken?

I can always define find-symbols
fallback to raise an exception but I was keen on having a cleaner way to do it.

Can someone please have a look at https://docs.racket-lang.org/reference/printing.html and confirm that the first paragraph on print
doesn’t make sense?

Here:


it seems to say that print
always behaves like write
.

I think it meant to say that when print-as-expression
is set to #f
, then print
mode is like display
mode.

Is this correct/

?

@pocmatos I think the text is accurate

what’s it’s saying is that it prints something like (list 1 2 3)
as '(1 2 3)
, which when you evaluate it, produces the value you started with

oK, let me see if I understand it then. n

whereas write
would produce (1 2 3)
, which when you evaluate it is an error, but if you read
it produces the value you started with

[samth@huor:~/tmp plt] r
Welcome to Racket v7.0.0.1.
> (print (list 1 2 3))
'(1 2 3)
> (write (list 1 2 3))
(1 2 3)
> (print-as-expression #f)
> (print (list 1 2 3))
(1 2 3)

But it says: when print-as-expression
is #t
it prints most datatypes in such a way that evaluating the output as expression produces a value that is equal?
to the printed value.

But that is also what the write
docs say: write mode prints core datatypes in such a way that using read on the output produces a value that is equal? to the printed value;

And then it says when print-as-expression
is #f
it behaves like write
. it seems that the docs imply that it always behaves like write
.

I understand your example and think the code examples are as expected. My issue is with the documentation.

it says that print-as-expression
being #t is the default mode

ok, but that doesn’t invalidate what I just wrote about the docs.

I’m still confused as to what you think is wrong in the docs

the statements about print
and write
are not the same

the difference is: “evaluating the output as expression” vs “using read on the output”

ah…

I missed that difference.

my apologies, it’s all cleared up.

Thanks!

@greg regarding racket-mode
, if I write dict?
it becomes bold. If I write sequenceof
it doesn’t. Where does racket-mode
find these names? It doesn’t seem to be from requires, because sequenceof
from data/collections
is never emboldened and dict?
is emboldened even when I am in racket/base
without a racket/dict
require.

@pocmatos The names comes from here https://github.com/greghendershott/racket-mode/blob/master/keywords.rkt. See the comment for rationale.

Thanks.

@greg, makes sense, thanks.

That provides some font-lock (as Emacs calls syntax highlighting) that works for racket-mode
on plain files even when no *Racket REPL*
buffer exists or matches the file being edited.

Could there be some other layer that tries to change/augment this for buffers that have/had a live REPL, or something? Sure. But. It’s a level of complexity that hasn’t seemed justified, no one has seemed to care enough to-date.

@greg the comments mention doing something live. Would this not be feasible at all? I assume that emacs does some font-lock regeneration every time the buffer changes, what if there’s some live thing going on that updates it even if with a slightly delay…

Understood.

@pocmatos define-generics
does support this feature. You’re probably running into a subtly with the way generic methods work with lexical scope. In a given block of method implementations, the names for the methods of that interface are either bound to the specific implementation defined in that block or raise a “method not implemented” syntax error. In other words, inside a block of method definitions, a method name never refers to the generic method. To refer to the generic method in that context, you need the define/generic
form.

Here’s a working version of your example: #lang racket
(require racket/generic
rackunit)
(define-generics symbolics
(find-symbols symbolics) ;; returns list of all symbols
(any-symbols? symbolics) ;; return true if there are any symbols
#:fallbacks
[(define/generic find-symbols* find-symbols)
(define (any-symbols? s)
(not (null? (find-symbols* s))))])
(struct example (lst)
#:transparent
#:methods gen:symbolics
[(define (find-symbols s)
(example-lst s))])
(check-false (any-symbols? (example '())))
(check-true (any-symbols? (example '(apple))))

@blerner Thanks for the reassurance and suggestion. @nocheroot Thanks! That interface appears to require administrator access, so it wouldn’t be a good solution for Racket in general. Anyway, I agree with you that it would be easy for automatic handling here to be too much. For now, I’ve opted to highlight potential problems in the Racket documentation and changed only delete-directory/files
and a package-manager-specific functions to try to avoid problems.

@mflatt Whoops. So used to all of my code being launched by elevated processes or running as system. Slipped my mind elevation was required for this.

ISTM that, for sporadic and short-lived contention such as antivirus, a relatively simple retry-these-files worklist and some backoff time/max-#-of-retries trick might suffice. anything else is probably Too Gnarly to try to automate properly

You can also potentially schedule those files to be deleted on next book (see MoveFileEx
with the MOVEFILE_DELAY_UNTIL_REBOOT
flag — https://msdn.microsoft.com/en-us/library/windows/desktop/aa365240(v=vs.85).aspx)

The following (implements recursive directory deletion in .NET) might be interesting, but I don’t think it has any extra tricks: https://github.com/dotnet/corefx/blob/master/src/System.IO.FileSystem/src/System/IO/FileSystem.Windows.cs#L434

Administrator rights not always necessary. :stuck_out_tongue: (The trick using AntiVirus quarantine is both :fire: and :scream:) https://sec-consult.com/en/blog/2018/06/pentesters-windows-ntfs-tricks-collection/

RacketCon 2018 - Please fill out this survey to let us know which teams & workshops we should organizer for Racket Office Hours: https://goo.gl/forms/flJSWxdM3gmmN7fw1

I would like to register for (eigth racketcon). Registration link says TBA…

small typo: DLS/DLSs vs DSL/DSLs

@steck has joined the channel

hello

hi

@gknauth Fixed. (I meant to update this morning, but forgot to sync to the live site.)

@mflatt Awesome, thanks, it worked!

whistles “never gonna give you up”

Seriously: Strange Loop retweeted this to 10K followers so hopefully some people will register before they commit to hotel or flight itins https://twitter.com/greghendershott/status/1007339018361679872

(Every year (except last) I chat with people at STL who say, “oh dang, I’m flying out or I would have done RacketCon, too”. Some % are just being polite, I’m sure. :slightly_smiling_face: But some probably would join if they remember.)

Are there any hackathons for people who want to contribute to racket per se? I think these are the kinds of things that probably happen at racketcon too