[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology

Name
Options
Comment
Verification
4chan Pass users can bypass this verification. [Learn More] [Login]
File
  • Please read the Rules and FAQ before posting.
  • You may highlight syntax and preserve whitespace by using [code] tags.

08/21/20New boards added: /vrpg/, /vmg/, /vst/ and /vm/
05/04/17New trial board added: /bant/ - International/Random
10/04/16New board for 4chan Pass users: /vip/ - Very Important Posts
[Hide] [Show All]


[Advertise on 4chan]


Ever used this? I plan on using it for lessening the verbosity of some SQL constructs (such as an immutable column macro that generates the necessary functions/triggers).
https://www.slideserve.com/sheryl/m4-macro-processing-language
Are there better modern alternatives (maybe something that is Lispy in nature)?

BTW: the new thread captcha is far more cursed than the new post one. Also, because the thread form details are cleared, humans must re-select everything manually upon failure, incredibly fucking annoying.
>>
Literally the only use of M4 is in compiling GNU Make.
>>
>>107603492
Its old so I used it in a production system like 20 years ago. Worked well, but was hideously ugly once it got large. If I hard to do it again I'd just use Jinja2.
There's no preprocessor that I know of thats "like LISP" I think you'd end up writing lisp macros in actual SBCL. If you want a classic "small fast low startup latency lisp" thats a hell of a thing to find, good luck.
>>
>>107603492
Trust me, you want to write SQL before you want to write M4 soup. It's an absolutely atrocious abomination of a language.

If you truly hate SQL - and I get that - use PRQL.
>>
>>107603525
>>107604457
I think I am going to go with a Babashka script that locates SQL comments of a certain format and replaces them with their contents after an EVAL
a preliminary function that is proving well:
(def begin-emission "-- Begin RoboSQL emission...")

(def end-emission "-- ...End RoboSQL emission")

(defn
immutable-column
[schema table column]
(format
"
%s
create function %s.%s_%s_tr_bu_fn()
returns trigger
as $$
begin
if old.%s is distinct from new.%s
then
raise exception '`%s` was updated.';
end if;

return new;
end;
$$
language plpgsql;

create trigger %s_%s_tr_bu
before update of %s
on %s.%s
for each row execute function %s.%s_%s_tr_bu_fn();
%s"
begin-emission
schema table column
column column
column
table column
column
schema table
schema table column
end-emission))

you would call it like:
--ROBO (immutable-column "some_scm" "some_tbl" "some_column")

or
/*ROBO
; Do whatever Babashka that you want that returns a string.
ROBO*/
>>
My custom mips assembler used m4
>>
>>107604875
> custom assembler
This. I've used it for all kinds of one-off languages and things where I wanted to simply add macro capability by didn't want to write 1000's more lines into the parser-generator.

nowadays, I tend to use the C pre-processor a lot more-- something else that works on nearly anything. It can even make "golang" usable.
The original bourne shell was written in BCPL and used #defines to turn his BCPL into C code because he couldn't figure out C.



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.