Discussion
Loading...

Post

  • About
  • Code of conduct
  • Privacy
  • Users
  • Instances
  • About Bonfire
Konstantin 🔭
@konstantin@hachyderm.io  ·  activity timestamp 6 days ago

I'm having way too much fun with #kotlin letting me name functions with free text :D

Shows a unit test with the function named "USA acronym should dusplay as USA not Usa"
Shows a unit test with the function named "USA acronym should dusplay as USA not Usa"
Shows a unit test with the function named "USA acronym should dusplay as USA not Usa"
  • Copy link
  • Flag this post
  • Block
Ian Wagner
@ianthetechie@fosstodon.org replied  ·  activity timestamp 6 days ago

@konstantin lol in my brief stint as a full time Kotlin dev our team did exactly this for tests lol

  • Copy link
  • Flag this comment
  • Block
Konstantin 🔭
@konstantin@hachyderm.io replied  ·  activity timestamp 6 days ago

@ianthetechie haha, sounds like fun :D

  • Copy link
  • Flag this comment
  • Block
Christian Tietze
@ctietze@mastodon.social replied  ·  activity timestamp 6 days ago

@konstantin @ianthetechie in every meetup, the Kotlin folks rave about this being a thing. I believe they all do that!

(I'm really happy that we have this in Swift now, too)

  • Copy link
  • Flag this comment
  • Block
Konstantin 🔭
@konstantin@hachyderm.io replied  ·  activity timestamp 6 days ago

@ctietze @ianthetechie Now, we can be chaos in every language 🚀😁!

  • Copy link
  • Flag this comment
  • Block
Nick Lockwood
@nicklockwood@mastodon.social replied  ·  activity timestamp 6 days ago

@konstantin swift has this too now FYI (since 6.2): https://useyourloaf.com/blog/swift-raw-identifiers/

  • Copy link
  • Flag this comment
  • Block
Konstantin 🔭
@konstantin@hachyderm.io replied  ·  activity timestamp 6 days ago

@nicklockwood Ohhh that's amazing. I'm so going make proper (over)use of it 😁

  • Copy link
  • Flag this comment
  • Block
Kristoffer Lawson
@Setok@attractive.space replied  ·  activity timestamp 6 days ago

@konstantin interesting. You can do the same in Tcl (indeed a procedure name could even be some binary data). Additionally you can have aliases, so you could indeed use that pattern you describe to have a rich explanation of function as the original name, and then an alias for actual use.

  • Copy link
  • Flag this comment
  • Block
Konstantin 🔭
@konstantin@hachyderm.io replied  ·  activity timestamp 6 days ago

@Setok Oh really, that sounds cool. I guess writing tests is really the perfect use case for this, it's not a function you'd need to call or type by hand. It can get cumbersome in other use cases

  • Copy link
  • Flag this comment
  • Block
Kristoffer Lawson
@Setok@attractive.space replied  ·  activity timestamp 6 days ago

@konstantin can also be used for encapsulation of a sort. At least in #Tcl, procedures (functions) can be created dynamically and with any names. So you could have a procedure that creates a new procedure (even like what you described), and returns the name which you could then set to a variable and use it that way (indeed OO systems tend to do that). Using aliases you could even create a command to do:

newProc hello {Does the usual hello world thing} {
puts “Hello, world”
}

  • Copy link
  • Flag this comment
  • Block
Kristoffer Lawson
@Setok@attractive.space replied  ·  activity timestamp 6 days ago

@konstantin that newProc would create a proc with the name given in the description, and then create an alias to it (‘hello’ in this case).

Endless possibilities :)

  • Copy link
  • Flag this comment
  • Block
Log in

bonfire.cafe

A space for Bonfire maintainers and contributors to communicate

bonfire.cafe: About · Code of conduct · Privacy · Users · Instances
Bonfire social · 1.0.0 no JS en
Automatic federation enabled
  • Explore
  • About
  • Members
  • Code of Conduct
Home
Login