
switch to continuation marks?

Tried that. It’s… 2x slower. I don’t know what went wrong.

parameterize
already uses continuation marks though.

Here’s an adaptation from https://srfi.schemers.org/srfi-157/srfi-157.html


In my application which uses parameters heavily, it’s 2x slower.

@wanpeebaw It’s much better than mere occurrences since it cooperates with check-syntax to distinguish between the different lexical scopes:

@laurent.orseau Well, AFAIK, many IDEl’s highlight occurrence feature are also semantics aware. For example Android Studio (IntelliJ), VSCode…

Really, are they? I’m surprised, but that’s cool.

IIRC, it starts from Eclipse JDT. Which equipped with an incremental compiler.

I’ve been using Racket for too long :smile:

Are syntax-properties appropriate for tasks like tracking static type information?

Probably it walk through a large proportion of mark stacks if you have many different keys, while with parameter it just find the closest parameterization.

yes

@sorawee We (Neil and I) had the same problem when we implemented with-modulus
in math/number-theory
. The first version used parameters and was somewhat slow. The solution was to use a cache. See https://github.com/racket/math/blob/master/math-lib/math/private/number-theory/modular-arithmetic-base.rkt

@sorawee Your replacement for parameterize
seems faster to me, but maybe my tests aren’t using parameters in the same way as your application. Here’s what I tired: https://gist.github.com/mflatt/9e307484d3288f7784096dfddd70e12a

Roughly, the original idea was to teach using functional programming. Doing that made them realize that they needed multiple separate languages for teaching, thus an IDE that supported that. That led to research on supporting multiple languages, and ultimately to the language-oriented approach now in Racket.

You can check out turnstile, which does this: https://bitbucket.org/stchang/macrotypes/src/master/

when using define-runtime-path
if i raco exe
my program, the relative paths are according to the original source file and not the new executable, how do i fix it? eg: (define-runtime-path DB-FILE "mydb.db")
(define WCONN (sqlite3-connect #:database DB-FILE
#:mode 'create))

I think you might want raco distribute

In general define-runtime-path
is specifying a path that should be interpreted relative to the source file, so that it’s the same path regardless of where you execute the racket file or executable.

oh ok that works, now it puts the file in some nested directory… but it at least goes along with my exe, thank you!

Right, if what you want is to be able to move things and have files come along, then you want raco distribute

If you want a relative path, then it depends what you want that path to be relative to.

let’s say i want a config file to auto generate when opening my exe, i had already heard of (find-system-path 'run-file)
that sometimes returns the racket exe of the drracket executable which is not what i want, now fair enough i just have to make a procedure that handles those edge cases. but i wanted to know if there was a more straightforward way of doin this.

what do you want it to produce if you just run the file with racket foo.rkt
?

well… if my source code is composed of many files, and i made a tool that i could carry around and only affect the directory is in… i could just pack them into an executable and voila.
also i run into an issue in Windows where i dont seem to be able to open more than one script with gracket
unless i raco exe
it.

i can with racket
but it shows the console screen, and that is annoying

What do you mean by more than one script?

Also, I don’t understand what your suggestion is for my question

okok yeah i dont seem to have answered your question, basically what i’ve been using define-runtime-path
until now is for having references to file that will be created with dumped information, a db file in the case of a database, maybe a json config file.
I wanted a straightforward solution for when I either execute my program with racket/drracket/gracket to get these paths and when i pack my program with raco exe
aaah… I don’t think i understand the question though.
By more than one script i mean physically cannot have more than one instance of gracket running, this is circumvented by using raco exe
, but if i have a script with let’s say #lang racket/gui
(send (new frame% [label ""]) show #t)
and then i name it A.rkt and have copy of it A-copy.rkt i try to run both with gracket <namefile>
and only the first one will appear and the other silently do nothing

Right, the question is if you had a function that magically gave you the answer you wanted, what would it produce if you hadn’t used raco exe

That really sounds like a bug

It’s possible that Windows is weird relative to other platforms but I don’t think so in this case

uhh not really i dont think so? i mean my problem originated that the examples for define-runtime-path
[https://docs.racket-lang.org/reference/Filesystem.html?q=define-runtime-path#%28form._%28%28lib._racket%2Fruntime-path..rkt%29._define-runtime-path%29%29\|link] make it seems as you can have always a relative path to a file, and that it cooperated with raco exe
. im backtracking a little here.
did i confuse you with that thing i said about gracket? because im confused now too. :(

define-runtime-path
does cooperate with raco exe
, and it does work with relative paths, so I’m not sure what you’re saying.

My point is that if you want a relative path, then you have to decide “relative to what” and it’s not obvious what the right answer is.

let’s say i have
;; main.rkt
#lang racket
(require "other.rkt")
(dump)
;; other.rkt
#lang racket
(require racket/runtime-path)
(provide dump)
(define-runtime-path data.txt "data.txt")
(define (dump)
(call-with-output-file data.txt
(lambda (out)
(writeln "hello there" out))
#:exists 'replace
#:mode 'text))
raco exe main.rkt
i move main.exe
to folder bin
i run it, and the data.txt
file will be created in the parent directory of bin

and i dont want that…

what do you want the function to do if you do racket main.rkt
? Or cd ..; racket code/main.rkt
?

i want it to write data.txt in the same folder as main.exe which as you mentioned raco distribute kinda does that, except that it is not in the same folder main.exe but a nested directory that i have no control over it. based on my example above i get this
\|- main.rkt
\|- other.rkt
\|- data.txt
\|
\|- bin
\|--- main.exe
after executing main.exe
i want \|- main.rkt
\|- other.rkt
\|
\|- bin
\|--- main.exe
\|--- data.txt

Right but what do you want to happen when you don’t create an executable?

where i to run racket main.rkt
i want the first file tree

what about when you run racket foo/main.rkt
?

ah also the same as the first file tree, yeah… i cant use (current-directory)
well not in a straightforward way, but i think about what if i change the cwd in a batch file or the like… idk

So you want something that’s in the same location as what the (define-runtime-path ...)
specified if you run it without raco exe
, but you want it to be relative when you move the executable file?

yeah exactly!

Note that such behavior definitely won’t work if you’re reading the file

if im reading data.txt?

Just checking, can you do this with these editors: https://www.youtube.com/watch?v=XinMxDLZ7Zw&t=4s

Right

Because data.txt is in some specific place, not a place that moves with the executable

Is there a rationale for naming this lvp
? lvp ::= pat ooo greedily match pat instances
\| pat match pat
I keep thinking “list value pair”, but it’s actually “pattern, or lots of patterns”


v is probably “variable” as in “variable in length”

p is definitely “pattern”

yeah how can i achieve that? how can i detect if i am running from an executable made with raco exe?

Why do you want different behavior?

because i want them to act as different entities.
when running with racket
is probably because im developing it,
if im running it “compiled”, it’s probably because i have multiple copies of the file and want it to keep configurations, data, etc separated…

Yea, I think it might actually be “length variable pattern”

list doesn’t make too much sense here either, maybe

The bad news is that define-runtime-path, and raco exe/distribute, and overall racket as a whole, are designed to preserve behavior through different compilation modes

huh i see…

ok so after some searching, (find-system-path 'run-file)
almost always gets the file it was executed, unless it was tampered with such as inside DrRacket… so for my purposes it will work, well enough i think. https://github.com/racket/distributed-places/blob/3f4a1f43430216871e8cc7a6ecbd2a03530a9bfb/distributed-places-lib/racket/place/distributed.rkt#L126\|distributed.rkt#L126 this gave me some clues. thank you for your guidance

My guess is “list-valued pattern”.

Yes, it’s call Extract Method. It’s a code refactoring feature. https://www.jetbrains.com/help/idea/extract-method.html
There are also other kinds of refactoring actions like Extract constant, Extract field, Extract Parameter, Extract/Introduce variable, Rename, Inline… https://www.jetbrains.com/help/idea/refactoring-source-code.html

My M1 based Macbook Pro 13 comes 11/24. DrRacket will be one of the first things I’ll install. I’ll let you know. It may be that it just runs fine under Rosetta x86 emulation. It’s going to be a while before the package managers (brew, nix, macports, etc.) work at all.

https://github.com/racket/racket/issues/3513#issuecomment-730422639\|https://github.com/racket/racket/issues/3513#issuecomment-730422639 suggests that it won’t work quite yet

