4

Am I the only one who wants to be able to write functions in a human readable way, allowing for parameter in-between the words?

Instead of defining:

const enforceStringEndsWithChar(string: string, char: string) => {...}

I want to define it as:

const enforce(str: string)EndsWith(char: string) => {...}

.
.
.

I'll see myself out.

Comments
  • 5
    yes, just you bud.
  • 2
    This is the reason why so many fluid apis exist... no you are definitely not the only one
  • 3
    Named args help this a fair bit, then you can pretty easily have:

    enforceString(s, endsWith=x)
  • 0
    Trust me, they exist.

    Let me introduce you to javascript chaining and Ruby/Rails, specifically ActiveRecord and RSpec.

    ActiveRecord's syntax is like LINQ, except pretty.

    ActiveRecord example:

    Movies.where(musical: true, chickflick: true, drama: false).where('created_at >= ?', 15.years.ago).where('rating >= ?', 3.5).sort(title: :asc)

    World::Population.human.alive.female.single.where(age: 18..28).where('iq >= ?', 140).where(profession: [:dev, :qa, :gamer, :scientist, :engineer]).where(likes_musicals: true, personality: [:intj, :intp, :entp]).where.not(sickly: true).order(iq: :desc)

    RSpec example:

    describe Object do
    let(:new_instance) { FactoryBot.build(:object) }

    it "changes the count after saving" do
    expect { new_instance.save }.to change { Object.count }.from(0).to(1)
    end
    end
  • 0
    You're not the only one. To my knowledge Smalltalk can do that, for example.
  • 0
    Take a look at the kotlin infix: https://kotlinlang.org/docs/...

    But it has its limitation, you always need VFV, something like VFFVF or VF or FV does not work.. (v=value, f= function)
  • 0
    @Emphiliis huh. Kinda strange that it's specified by the func, not just available anywhere. Feels like allowing library authors to dictate coding style of applications...
  • 0
    Oh my fucking God what is that abomination
Add Comment