Using = for something other than assignment?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Using = for something other than assignment?

The_Danimal
could I do something like:

foo bar = baz

and have that result in calling a method? Perhaps bar_=(baz: Baz) or
something? Or something more flexible?


in my context:

define f = 'x + 3
Reply | Threaded
Open this post in threaded view
|

Re: Using = for something other than assignment?

David Hall-11
You can make

"define('f) = 'x + 3" work fairly easily.

object define {
  def update(f : Symbol, y : X) = //...
}

Getting rid of those parens may not be possible?

-- David

On Wed, Jul 30, 2008 at 11:47 AM, Daniel Green <[hidden email]> wrote:

> could I do something like:
>
> foo bar = baz
>
> and have that result in calling a method? Perhaps bar_=(baz: Baz) or
> something? Or something more flexible?
>
>
> in my context:
>
> define f = 'x + 3
>
Reply | Threaded
Open this post in threaded view
|

Re: Using = for something other than assignment?

The_Danimal
> object define {
>  def update(f : Symbol, y : X) = //...
> }
>
Awesome, thanks! Works like a charm.

> Getting rid of those parens may not be possible?
>
scala> define 'f = "foo"
define 'f = "foo"
<console>:5: error: value update is not a member of object Symbol
       define 'f = "foo"


On Wed, Jul 30, 2008 at 3:16 PM, David Hall <[hidden email]> wrote:

> You can make
>
> "define('f) = 'x + 3" work fairly easily.
>
> object define {
>  def update(f : Symbol, y : X) = //...
> }
>
> Getting rid of those parens may not be possible?
>
> -- David
>
> On Wed, Jul 30, 2008 at 11:47 AM, Daniel Green <[hidden email]> wrote:
>> could I do something like:
>>
>> foo bar = baz
>>
>> and have that result in calling a method? Perhaps bar_=(baz: Baz) or
>> something? Or something more flexible?
>>
>>
>> in my context:
>>
>> define f = 'x + 3
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Using = for something other than assignment?

The_Danimal
>> Getting rid of those parens may not be possible?
>>
> scala> define 'f = "foo"
> define 'f = "foo"
> <console>:5: error: value update is not a member of object Symbol
>       define 'f = "foo"
>
Oh! Perhaps with implicit conversion or something?

On Wed, Jul 30, 2008 at 3:31 PM, Daniel Green <[hidden email]> wrote:

>> object define {
>>  def update(f : Symbol, y : X) = //...
>> }
>>
> Awesome, thanks! Works like a charm.
>
>> Getting rid of those parens may not be possible?
>>
> scala> define 'f = "foo"
> define 'f = "foo"
> <console>:5: error: value update is not a member of object Symbol
>       define 'f = "foo"
>
>
> On Wed, Jul 30, 2008 at 3:16 PM, David Hall <[hidden email]> wrote:
>> You can make
>>
>> "define('f) = 'x + 3" work fairly easily.
>>
>> object define {
>>  def update(f : Symbol, y : X) = //...
>> }
>>
>> Getting rid of those parens may not be possible?
>>
>> -- David
>>
>> On Wed, Jul 30, 2008 at 11:47 AM, Daniel Green <[hidden email]> wrote:
>>> could I do something like:
>>>
>>> foo bar = baz
>>>
>>> and have that result in calling a method? Perhaps bar_=(baz: Baz) or
>>> something? Or something more flexible?
>>>
>>>
>>> in my context:
>>>
>>> define f = 'x + 3
>>>
>>
>
Reply | Threaded
Open this post in threaded view
|

Re: Using = for something other than assignment?

Ingo Maier-3
Daniel Green wrote:
>>> Getting rid of those parens may not be possible?
>>>
>> scala> define 'f = "foo"
>> define 'f = "foo"
>> <console>:5: error: value update is not a member of object Symbol
>>       define 'f = "foo"
>>
> Oh! Perhaps with implicit conversion or something?

The error message above is more than strange, I filed a ticket:
https://lampsvn.epfl.ch/trac/scala/ticket/1158. I'd love to "override" =
for the signal stuff or properties too, but currently

foo()= baz

or

define(foo) = baz

is all you can do, I guess.

Ingo