pocmatos
2018-6-14 09:16:38

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 )


pocmatos
2018-6-14 09:18:17

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?


pocmatos
2018-6-14 09:18:40

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


pocmatos
2018-6-14 12:04:20

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?


pocmatos
2018-6-14 12:04:22

Here:


pocmatos
2018-6-14 12:05:02

pocmatos
2018-6-14 12:06:05

it seems to say that print always behaves like write.


pocmatos
2018-6-14 12:06:39

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


pocmatos
2018-6-14 12:06:42

Is this correct/


pocmatos
2018-6-14 12:06:43

?


samth
2018-6-14 13:07:28

@pocmatos I think the text is accurate


samth
2018-6-14 13:08:24

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


pocmatos
2018-6-14 13:08:45

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


samth
2018-6-14 13:08:54

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
2018-6-14 13:09:49
[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)

pocmatos
2018-6-14 13:10:16

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.


pocmatos
2018-6-14 13:10:43

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;


pocmatos
2018-6-14 13:11:16

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.


pocmatos
2018-6-14 13:11:38

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


samth
2018-6-14 13:14:28

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


pocmatos
2018-6-14 13:16:15

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


samth
2018-6-14 13:16:34

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


samth
2018-6-14 13:17:02

the statements about print and write are not the same


samth
2018-6-14 13:17:34

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


pocmatos
2018-6-14 13:18:18

ah…


pocmatos
2018-6-14 13:18:22

I missed that difference.


pocmatos
2018-6-14 13:18:41

my apologies, it’s all cleared up.


pocmatos
2018-6-14 13:18:45

Thanks!


pocmatos
2018-6-14 14:21:36

@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.


greg
2018-6-14 14:26:56

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


pocmatos
2018-6-14 14:27:28

Thanks.


pocmatos
2018-6-14 14:28:42

@greg, makes sense, thanks.


greg
2018-6-14 14:28:44

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.


greg
2018-6-14 14:30:01

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.


pocmatos
2018-6-14 14:30:03

@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…


pocmatos
2018-6-14 14:30:17

Understood.


philip.mcgrath
2018-6-14 16:29:27

@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.


philip.mcgrath
2018-6-14 16:30:35

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))))


mflatt
2018-6-14 16:58:06

@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.


nocheroot
2018-6-14 17:02:51

@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.


blerner
2018-6-14 17:03:44

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


blerner
2018-6-14 17:06:47

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)


samth
2018-6-14 17:13:05

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


greg
2018-6-14 18:00:58

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/


jeapostrophe
2018-6-14 18:07:45

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


gknauth
2018-6-14 18:09:41

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


gknauth
2018-6-14 18:13:45

small typo: DLS/DLSs vs DSL/DSLs


steck
2018-6-14 18:20:28

@steck has joined the channel


steck
2018-6-14 18:23:30

hello


samth
2018-6-14 18:29:54

hi


mflatt
2018-6-14 19:03:51

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


gknauth
2018-6-14 19:06:29

@mflatt Awesome, thanks, it worked!


greg
2018-6-14 19:09:38

whistles “never gonna give you up”


greg
2018-6-14 19:19:05

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


greg
2018-6-14 19:20:51

(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.)


krismicinski
2018-6-14 20:03:29

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