[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

unifying hash and proc syntax

Joel VanderWerf

3/22/2005 5:02:00 AM

Hey, crazy idea. Why not use the same syntax for hashes and arrays? For
example:

{
1 => 2,
2 => 3,
3 => 4,
|x|
x + 1
}

This is essentially a hash with a default_proc that adds 1 to its argument.

Leave out the => pairs and you get something that acts like a proc.
Leave out the |...|... construct and you get something that acts like a
hash. With both, it's a hash with a default proc.

It's backwards compatible.

Are there any syntactic ambiguities?


7 Answers

Joel VanderWerf

3/22/2005 5:44:00 AM

0

Joel VanderWerf wrote:
> Hey, crazy idea. Why not use the same syntax for hashes and arrays? For
^^^^^^
erm, procs


Hal E. Fulton

3/22/2005 6:18:00 AM

0

Joel VanderWerf wrote:
> Hey, crazy idea. Why not use the same syntax for hashes and arrays? For
> example:
>
> {
> 1 => 2,
> 2 => 3,
> 3 => 4,
> |x|
> x + 1
> }
>
> This is essentially a hash with a default_proc that adds 1 to its argument.
>
> Leave out the => pairs and you get something that acts like a proc.
> Leave out the |...|... construct and you get something that acts like a
> hash. With both, it's a hash with a default proc.

It's a fllor wax AND a dessert topping!

> It's backwards compatible.

Delicious! And just look at that shine!

> Are there any syntactic ambiguities?

Hmm, not sure. But it certainly gives me a headache to think about it.


Hal





Csaba Henk

3/22/2005 6:58:00 AM

0

On 2005-03-22, Joel VanderWerf <vjoel@PATH.Berkeley.EDU> wrote:
> example:
>
> {
> 1 => 2,
> 2 => 3,
> 3 => 4,
> |x|
> x + 1
> }
>
> This is essentially a hash with a default_proc that adds 1 to its argument.

Witty! What's somewhat dubious in it is melting two things which are so
different as objects. A hash is basicly transparent, a proc is basicly
opaque. And an object which has a proc as an attribute in some sense
won't just become a proc...

But, hm, all-in-all, I like it. I always tend to think of hashes as
mappings defined at finitely many places, abstracting from the data
structure which implements it (and gives it its name).

Csaba

MioMyo

6/18/2008 11:46:00 AM

0


http://tennesseepolicy.org/main/article.php?arti...
NASHVILLE - In the year since Al Gore took steps to make his home more
energy-efficient, the former Vice President's home energy use surged more
than 10%, according to the Tennessee Center for Policy Research.

"A man's commitment to his beliefs is best measured by what he does behind
the closed doors of his own home," said Drew Johnson, President of the
Tennessee Center for Policy Research. "Al Gore is a hypocrite and a fraud
when it comes to his commitment to the environment, judging by his home
energy consumption."

In the past year, Gore's home burned through 213,210 kilowatt-hours (kWh) of
electricity, enough to power 232 average American households for a month.

In February 2007, An Inconvenient Truth, a film based on a climate change
speech developed by Gore, won an Academy Award for best documentary feature.
The next day, the Tennessee Center for Policy Research uncovered that Gore's
Nashville home guzzled 20 times more electricity than the average American
household.

After the Tennessee Center for Policy Research exposed Gore's massive home
energy use, the former Vice President scurried to make his home more
energy-efficient. Despite adding solar panels, installing a geothermal
system, replacing existing light bulbs with more efficient models, and
overhauling the home's windows and ductwork, Gore now consumes more
electricity than before the "green" overhaul.

Since taking steps to make his home more environmentally-friendly last June,
Gore devours an average of 17,768 kWh per month -1,638 kWh more energy per
month than before the renovations - at a cost of $16,533. By comparison, the
average American household consumes 11,040 kWh in an entire year, according
to the Energy Information Administration.

In the wake of becoming the most well-known global warming alarmist, Gore
won an Oscar, a Grammy and the Nobel Peace Prize. In addition, Gore saw his
personal wealth increase by an estimated $100 million thanks largely to
speaking fees and investments related to global warming hysteria.

"Actions speak louder than words, and Gore's actions prove that he views
climate change not as a serious problem, but as a money-making opportunity,"
Johnson said. "Gore is exploiting the public's concern about the environment
to line his pockets and enhance his profile."

The Tennessee Center for Policy Research, a Nashville-based free market
think tank and watchdog organization, obtained information about Gore's home
energy use through a public records request to the Nashville Electric
Service.



"Screen Ranger" <ScreenRanger100@aol.com> wrote in message
news:J4idncMvS8G6BMXVnZ2dnUVZ_jKdnZ2d@posted.toastnet...
>
> "MioMyo" <USA_Patriot@Somewhere.com> wrote in message
> news:xi_5k.13018$Ri.2350@flpi146.ffdc.sbc.com...
>> Hypocrite doesn't begin to describe......
>>
>> And this accounts for but one........
>>
>> http://tennesseepolicy.org/main/article.php?arti...
>> NASHVILLE - In the year since Al Gore took steps to make his
>> home more
>> energy-efficient, the former Vice President's home energy
>> use surged more
>
>
> Well PUNK, He's one of a Kind, you Complained about him being
> a bad Example, you right but that's not where you focus if you
> have the brain. Gore is right, Current Admin borrowed Chinese
> Moneys to buy Arabic oil for your Consumption. That is the
> main point dragging the country down. Any How Gore has Money,
> He has the right to spend his money, he's one of important
> people, in fact BUSH stole his seat in the White House, you
> DORKS don't see your ugly side at all DipShit!

Where are lib-dork-lemmings such as yourself manufactured?


Dan Kimmel

6/18/2008 3:05:00 PM

0


"MioMyo" <USA_Patriot@Somewhere.com> wrote in message
news:jA66k.3532$cW3.3396@nlpi064.nbdc.sbc.com...
>
> http://tennesseepolicy.org/main/article.php?arti...

http://www.jwharrison.com/blog/2007/02/28/the-smear-campaign-agains...
Utility records have been cited to show that Gore paid a monthly average
of about $1,200 last year. Not mentioned by the conservative ?think-tank?
(which is a bit of an oxymoron) is the fact that the former-vice president's
costly bills are due in part to his participation in a ?green power
program,? in which he's been purchasing enough green power to balance 100
percent of his electricity consumption.

Gore also drives a hybrid and is renovating his house by installing solar
panels. He claims he is leading a carbon-neutral lifestyle by investing
money in projects to counteract other carbon emissions. Another interesting
fact is that the Nashville Electric Service claims they never gave the
Tennessee Center for Policy Research any information regarding Gore?s
electric bill, nor have they ever received a request.




Larry Hewitt

6/18/2008 4:27:00 PM

0


"CB" <CB@PrayForMe.com> wrote in message
news:4858d673$0$7077$4c368faf@roadrunner.com...
>
> "Screen Ranger" <ScreenRanger100@aol.com> wrote in message
> news:J4idncMvS8G6BMXVnZ2dnUVZ_jKdnZ2d@posted.toastnet...
>>
>> "MioMyo" <USA_Patriot@Somewhere.com> wrote in message
>> news:xi_5k.13018$Ri.2350@flpi146.ffdc.sbc.com...
>>> Hypocrite doesn't begin to describe......
>>>
>>> And this accounts for but one........
>>>
>>> http://tennesseepolicy.org/main/article.php?arti...
>>> NASHVILLE - In the year since Al Gore took steps to make his
>>> home more
>>> energy-efficient, the former Vice President's home energy
>>> use surged more
>>
>>
>> Well PUNK, He's one of a Kind, you Complained about him being
>> a bad Example, you right but that's not where you focus if you
>> have the brain. Gore is right, Current Admin borrowed Chinese
>> Moneys to buy Arabic oil for your Consumption. That is the
>> main point dragging the country down. Any How Gore has Money,
>> He has the right to spend his money, he's one of important
>> people, in fact BUSH stole his seat in the White House, you
>> DORKS don't see your ugly side at all DipShit!
>
> You must really hate America to think the election was stolen, good. I
> hope that hatred eats you to pain

Nah, we love america. Tha's why we fight bush fascism.

You are hte one filled with hate, racist.

Larry

> --
> CB
> DRILL HERE
> DRILL NOW
> PAYS LESS
> http://newt.org/tabid/102/articleType/ArticleView/articleId/3463/De...
>
>
> What put's Algore in his lockbox?
> http://home.austarnet.com.au/yours/Global%20Warming%20P...
>
> 2006 power bill
> http://www.coxandforkum.com/archives/07.03.04.ConspicCon...
>
> Global warming on Mars
> In its ninth year in orbit around Mars, NASA's Mars Global Surveyor has
> made
> a number of surprising discoveries. For three Mars summers in a row,
> deposits of frozen carbon dioxide near Mars' south pole have shrunk from
> the
> previous year's size, suggesting a climate change in progress. Apparently,
> President Bush's environmental policies are so destructive that they are
> causing global warming throughout the solar system.
> --Harry Dope
>


CB@PrayForMe.com

6/23/2008 9:40:00 AM

0


"Larry Hewitt" <larryhewi@comporium.net> wrote in message
news:dNudnZekYYb4qsTV4p2dnAA@comporium.net...
>
> "CB" <CB@PrayForMe.com> wrote in message
> news:4858d673$0$7077$4c368faf@roadrunner.com...
>>
>> "Screen Ranger" <ScreenRanger100@aol.com> wrote in message
>> news:J4idncMvS8G6BMXVnZ2dnUVZ_jKdnZ2d@posted.toastnet...
>>>
>>> "MioMyo" <USA_Patriot@Somewhere.com> wrote in message
>>> news:xi_5k.13018$Ri.2350@flpi146.ffdc.sbc.com...
>>>> Hypocrite doesn't begin to describe......
>>>>
>>>> And this accounts for but one........
>>>>
>>>> http://tennesseepolicy.org/main/article.php?arti...
>>>> NASHVILLE - In the year since Al Gore took steps to make his
>>>> home more
>>>> energy-efficient, the former Vice President's home energy
>>>> use surged more
>>>
>>>
>>> Well PUNK, He's one of a Kind, you Complained about him being
>>> a bad Example, you right but that's not where you focus if you
>>> have the brain. Gore is right, Current Admin borrowed Chinese
>>> Moneys to buy Arabic oil for your Consumption. That is the
>>> main point dragging the country down. Any How Gore has Money,
>>> He has the right to spend his money, he's one of important
>>> people, in fact BUSH stole his seat in the White House, you
>>> DORKS don't see your ugly side at all DipShit!
>>
>> You must really hate America to think the election was stolen, good. I
>> hope that hatred eats you to pain
>
> Nah, we love america. Tha's why we fight bush fascism.

America has a capital "A"

>
> You are hte one filled with hate, racist.

At the very least I have enough love and respect to capitalize the word

>> CB
>> DRILL HERE
>> DRILL NOW
>> PAYS LESS
>> http://newt.org/tabid/102/articleType/ArticleView/articleId/3463/De...

Return America to the super power Republicans brought her too

Vote for the Energy candidate, not the 'pie in the sky', technology will
save us dude.


>>
>>
>> What put's Algore in his lockbox?
>> http://home.austarnet.com.au/yours/Global%20Warming%20P...
>>
>> 2006 power bill
>> http://www.coxandforkum.com/archives/07.03.04.ConspicCon...
>>
>> Global warming on Mars
>> In its ninth year in orbit around Mars, NASA's Mars Global Surveyor has
>> made
>> a number of surprising discoveries. For three Mars summers in a row,
>> deposits of frozen carbon dioxide near Mars' south pole have shrunk from
>> the
>> previous year's size, suggesting a climate change in progress.
>> Apparently,
>> President Bush's environmental policies are so destructive that they are
>> causing global warming throughout the solar system.
>> --Harry Dope
>>
>
>