Beehaw
  • Communities
  • Create Post
  • search
    Search
  • Login
  • Sign Up
Dominik ( chrastecky@phpc.social )  to PHP@programming.dev · 2 years ago

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

media.phpc.social

message-square
10
link
fedilink
50

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

media.phpc.social

Dominik ( chrastecky@phpc.social )  to PHP@programming.dev · 2 years ago
message-square
10
link
fedilink

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

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

#php #cursed #wtf #programming @php

alert-triangle
You must log in or register to comment.
  • BatmanAoD ( BatmanAoD@programming.dev ) 
    link
    fedilink
    arrow-up
    19
    ·
    2 years ago

    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 ( shnizmuffin@lemmy.inbutts.lol ) 
    link
    fedilink
    English
    arrow-up
    13
    ·
    2 years ago

    No, my eyes! Forever unclean!

  • dan ( dan@upvote.au ) 
    link
    fedilink
    arrow-up
    10
    ·
    2 years ago

    What a terrible day to have eyes

  • TomasEkeli ( TomasEkeli@programming.dev ) 
    link
    fedilink
    arrow-up
    8
    ·
    2 years ago

    no. never wanted that.

  • zygo_histo_morpheus ( zygo_histo_morpheus@programming.dev ) 
    link
    fedilink
    arrow-up
    7
    ·
    edit-2
    2 years ago

    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);
    
  • Michael ( michael@mstdn.thms.uk ) 
    link
    fedilink
    arrow-up
    5
    ·
    2 years ago

    @chrastecky @php

  • Python ( python@programming.dev ) 
    link
    fedilink
    arrow-up
    4
    ·
    2 years ago

    huh, that does look kinda clean though

    • Dominik ( chrastecky@phpc.social ) OP
      link
      fedilink
      arrow-up
      5
      ·
      2 years ago

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

  • CubbyTustard ( CubbyTustard@reddthat.com ) 
    link
    fedilink
    arrow-up
    2
    ·
    2 years ago

    deleted by creator

  • Chao-c' ( xChaos@f.cz ) 
    link
    fedilink
    arrow-up
    1
    ·
    2 years ago

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

    • Dominik ( chrastecky@phpc.social ) OP
      link
      fedilink
      arrow-up
      1
      ·
      2 years ago

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

PHP@programming.dev

php@programming.dev

Subscribe from Remote Instance

Create a post
You are not logged in. However you can subscribe from another Fediverse account, for example Lemmy or Mastodon. To do this, paste the following into the search field of your instance: !php@programming.dev

Welcome to /c/php! This is a community for PHP developers and enthusiasts to share and discuss anything related to PHP. From the latest updates and tutorials, to your burning questions and amazing personal projects, we welcome all contributions.

Let’s foster an environment of respect, learning, and mutual growth. Whether you’re an experienced PHP developer, a beginner, or just interested in learning more about PHP, we’re glad to have you here!

Let’s code, learn, and grow together!

Visibility: Public
globe

This community can be federated to other instances and be posted/commented in by their users.

  • 2 users / day
  • 7 users / week
  • 48 users / month
  • 70 users / 6 months
  • 7 local subscribers
  • 837 subscribers
  • 146 Posts
  • 112 Comments
  • Modlog
  • mods:
  • Ategon ( Ategon@programming.dev ) 
  • mbd ( mbd@programming.dev ) 
  • BE: 0.19.21
  • Modlog
  • Legal
  • Instances
  • Docs
  • Code