codereport / jsource

J Language Source Code. Livestream links ⬇️
https://www.youtube.com/playlist?list=PLVFrD1dmDdvfVhYLU_iKkV67X9XqCJLWe
Other
38 stars 18 forks source link

Remove function argument macros? #60

Closed Sebanisu closed 3 years ago

Sebanisu commented 3 years ago

Maybe it's better to keep these? Till after we replace A and J names? It bothered me because I was looking for a function definition and it was hidden in a macro.

Known such macros: (using @juntuu's grep)

Example from j.h:

#define F1(f)           A f(J jt,    A w)
#define F2(f)           A f(J jt,A a,A w)

In j.h there are many of these wrapper macros. They take the name of a function and generate functions with the all same arguments. I'm currently experimenting on a branch of removing F1. I'm using a Regex replace:

(^|[ \t]+)F1\(([^\)]+?)\)

to:

A $2(J jt, A w)
codereport commented 3 years ago

If you can do this via regex I will merge it. I think replacing A & J will have to happen gradually.

juntuu commented 3 years ago

The following regex can be used to find this kind of definitions, there seems to be total of 30 different.

grep -rE '^\s*#define\s+\w+\(([^,]+)(,\w+)*\)\s+\w+\s+\1\(' jsrc/
Sebanisu commented 3 years ago

When I did a replace all the code wouldn't compile anymore. So I'm taking it slow one line at a time. Though I was thinking notepad++ might work better at searching. Clion caps searches at 100 results. Or I could spend an afternoon setting up vscode.

Update: Notepad++ is doing a great job at regex_replace for all the files in jsrc. :) I've removed F1 and F2. Waiting for tests to run before I goto the next macro.