Ever wanted to provide your arguments to a function as a comment?

Ever wanted to provide your arguments to a function as a comment?

https://gist.github.com/RikudouSage/18defbf1746322a289ae78b2980d0115

#php #cursed #wtf #programming @php

73 points · 12 comments · view on lemmy.world

12 Comments

BatmanAoD@programming.dev · 30 pts · 1y

the function reads the comment added after the function is called using a backtrace and uses them as arguments

How marvelously creative. What an abomination.

shnizmuffin@lemmy.inbutts.lol · 21 pts · 1y

No, my eyes! Forever unclean!

HowManyNimons@lemmy.world · 17 pts · 1y

Do you really want an answer for that?

dan@upvote.au · 16 pts · 1y

What a terrible day to have eyes

TomasEkeli@programming.dev · 12 pts · 1y

no. never wanted that.

zygo_histo_morpheus@programming.dev · 8 pts · 1y

This reminds me of a trick to get multiline strings in javascript before they where formally introduced. If you coerce a function in to a string you get the source code for that function, comments and all. This meant that you could write a function with multiline comments and then pick out the middle part. Haven't tested it so it's probably sligthly wrong but it was something like:

var multiLine = ('' + function () {/*
line 1
line 2
*/});
multiLine = multiLine.substring(16, multiLine.length-4);
python@programming.dev · 4 pts · 1y (1 reply)

huh, that does look kinda clean though

chrastecky@phpc.social · 5 pts · 1y

@python I mean, it's already an abomination, I can at least write a clean code.

michael@mstdn.thms.uk · 4 pts · 1y
Thcdenton@lemmy.world · 2 pts · 1y

CubbyTustard@reddthat.com · 2 pts · 1y
[ removed ]
xChaos@f.cz · 1 pts · 1y (1 reply)

@chrastecky @php eh, cože? proč?

chrastecky@phpc.social · 1 pts · 1y

@xChaos @php Někde jsem to viděl, že to někdo dělal pro Python a pobavilo mě to.