[bikeshed] Syntactic sugar idea

J

Joel VanderWerf

Mark said:
This is a neat idea, but wouldn't it conflict with the "fluent
interface" construct? Using Joel's DSL example:

config "my window" do
.width @x
.height @y
end

if we changed it to

config "my window" do
.width calculate_width
.height @y
end

Now how does the parser know what .height refers to: calculate_width,
or the implicit block variable?

Yeah, seems impossible. Maybe if there were some other character instead
of "." to signify sending a message to the block's "default object".
 
J

Jörg W Mittag

Daniel said:
But the fluent interface change *is* a parser change. My point was just
that seemingly trivial requests *can* make it into the core, whether
they're a syntax change or not.

Was that fluent interface syntax really a request? I cannot remember
anyone asking for it. I do, however, vividly recall various petitions
to *remove* that change.

jwm
 
D

Daniel Berger

It seems that often an object will be passed into a block only to invoke
a method of that object:
=A0 =A0arr.map{ |obj| obj.some_method }

So I had the (weird? stupid?) thought that it would be nice to have some
syntactic sugar like this:
=A0 =A0arr.map{ .some_method }

require 'enumerable/extra'

arr.map:)some_method)

Regards,

Dan
 
J

Jeremy McAnally

Mmm losing the $ would then render RSpec completely inoperable since
it has an it method.

--Jeremy

Forget the $ and you are spelling out a thought I was bearing with me
for quite some time, ty Daniel and Joel to bring this up :).
I always wanted an implicit _ parameter in blocks, as e.g.
3.times do puts _ end





--
Si tu veux construire un bateau ...
Ne rassemble pas des hommes pour aller chercher du bois, pr=E9parer des
outils, r=E9partir les t=E2ches, all=E9ger le travail=85 mais enseigne au= x
gens la nostalgie de l=92infini de la mer.

If you want to build a ship, don=92t herd people together to collect
wood and don=92t assign them tasks and work, but rather teach them to
long for the endless immensity of the sea.



--=20
http://jeremymcanally.com/
http://entp.com/
http://omgbloglol.com

My books:
http://manning.com/mcanally/
http://humblelittlerubybook.com/ (FREE!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,777
Messages
2,569,604
Members
45,219
Latest member
KristieKoh

Latest Threads

Top