Translation weirdness

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

Translation weirdness

Bert Freudenberg
 
Slang: foo isIntegerOop
C: interpreterProxy->isIntegerObject(foo)

Slang: interpreterProxy isIntegerObject: foo
C: (foo & 1)

SmartSyntaxInterpreterPlugin: y u no smart?

- Bert -

Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

timrowledge


On 14-03-2013, at 11:27 AM, Bert Freudenberg <[hidden email]> wrote:

>
> Slang: foo isIntegerOop
> C: interpreterProxy->isIntegerObject(foo)
>
> Slang: interpreterProxy isIntegerObject: foo
> C: (foo & 1)
>
> SmartSyntaxInterpreterPlugin: y u no smart?

Lack of love in the ten or so years since andy greenberg wrote it. Try leaving a kid without care for ten years and see what happens.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
My Go this  amn keyboar  oesn't have any  's.


Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

Eliot Miranda-2
In reply to this post by Bert Freudenberg
 


On Thu, Mar 14, 2013 at 11:27 AM, Bert Freudenberg <[hidden email]> wrote:

Slang:  foo isIntegerOop
C:      interpreterProxy->isIntegerObject(foo)

Slang:  interpreterProxy isIntegerObject: foo
C:      (foo & 1)

SmartSyntaxInterpreterPlugin: y u no smart?

IMO the second one is a bug.  Notionally plugins can't assume the representation of SmallInteger so they should always use  interpreterProxy->isIntegerObject(foo).  Inside, the interpreter knows the representation and hence uses (foo & 1).

And note that the slow form just got faster for internal primitives.  The Cog slang now generates

#if !defined(SQUEAK_BUILTIN_PLUGIN)
...
static sqInt (*isIntegerObject)(sqInt objectPointer);
...
#else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
...
extern sqInt isIntegerObject(sqInt objectPointer);
...

So no indirection through interpreterProxy for internal plugins.  So one thing to do is to generate

#if !defined(SQUEAK_BUILTIN_PLUGIN)
...
static sqInt (*isIntegerObject)(sqInt objectPointer);
...
#else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
...
# define isIntegerObject(objectPointer) ((sqInt)(objectPointer) & 1)
...


BTW, no senders of isIntegerOop in my Cog dev image.
--
best,
Eliot
Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

timrowledge


On 14-03-2013, at 12:56 PM, Eliot Miranda <[hidden email]> wrote:

>
> And note that the slow form just got faster for internal primitives.  The Cog slang now generates
>
> #if !defined(SQUEAK_BUILTIN_PLUGIN)
> ...
> static sqInt (*isIntegerObject)(sqInt objectPointer);
> ...
> #else /* !defined(SQUEAK_BUILTIN_PLUGIN) */
> ...
> extern sqInt isIntegerObject(sqInt objectPointer)


This I like. I should try some similar tricks on RISC OS, where I can - with some fiddling - directly link external plugins to the vm at load time, saving the indirection cost even there.


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Oscar Wilde: “Only the shallow know themselves.”



Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

Igor Stasenko
In reply to this post by Bert Freudenberg
 
On 14 March 2013 19:27, Bert Freudenberg <[hidden email]> wrote:
>
> Slang:  foo isIntegerOop
> C:      interpreterProxy->isIntegerObject(foo)
>
> Slang:  interpreterProxy isIntegerObject: foo
> C:      (foo & 1)
>
> SmartSyntaxInterpreterPlugin: y u no smart?
>
i'd say completely opposite.

when you looking at C source it is important to not lose track of what
was written in slang.
and in this regard, expression

  interpreterProxy->isIntegerObject(foo)

is preferable because you know exactly what's going on, in contrast to:

     (foo & 1)

where you can wonder, whether same expression is written in slang.. or
it is translation artefact.
We should avoid ambiguous stuff.. especially since you can always use macros
so it won't affect any speed whatsoever.

> - Bert -
>

--
Best regards,
Igor Stasenko.
Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

Bert Freudenberg


On 2013-03-14, at 21:18, Igor Stasenko <[hidden email]> wrote:

>
> On 14 March 2013 19:27, Bert Freudenberg <[hidden email]> wrote:
>>
>> Slang:  foo isIntegerOop
>> C:      interpreterProxy->isIntegerObject(foo)
>>
>> Slang:  interpreterProxy isIntegerObject: foo
>> C:      (foo & 1)
>>
>> SmartSyntaxInterpreterPlugin: y u no smart?
>>
> i'd say completely opposite.


You mean, "foo isIntegerOop" should generate "(foo & 1)", and "interpreterProxy isIntegerObject: foo" should generate "interpreterProxy->isIntegerObject(foo)", yes?

That would at least make sense, agreed.

I'd have expected both constructs to result in the same generated code, so they could be used interchangeably.

- Bert -

> when you looking at C source it is important to not lose track of what
> was written in slang.
> and in this regard, expression
>
>  interpreterProxy->isIntegerObject(foo)
>
> is preferable because you know exactly what's going on, in contrast to:
>
>     (foo & 1)
>
> where you can wonder, whether same expression is written in slang.. or
> it is translation artefact.
> We should avoid ambiguous stuff.. especially since you can always use macros
> so it won't affect any speed whatsoever.
>
>> - Bert -
>>
>
> --
> Best regards,
> Igor Stasenko.

Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

Igor Stasenko
 
On 15 March 2013 13:43, Bert Freudenberg <[hidden email]> wrote:

>
>
> On 2013-03-14, at 21:18, Igor Stasenko <[hidden email]> wrote:
>
>>
>> On 14 March 2013 19:27, Bert Freudenberg <[hidden email]> wrote:
>>>
>>> Slang:  foo isIntegerOop
>>> C:      interpreterProxy->isIntegerObject(foo)
>>>
>>> Slang:  interpreterProxy isIntegerObject: foo
>>> C:      (foo & 1)
>>>
>>> SmartSyntaxInterpreterPlugin: y u no smart?
>>>
>> i'd say completely opposite.
>
>
> You mean, "foo isIntegerOop" should generate "(foo & 1)", and "interpreterProxy isIntegerObject: foo" should generate "interpreterProxy->isIntegerObject(foo)", yes?
>

no i meant, both should generate

foo isIntegerOop => isIntegerOop(foo)
interpreterProxy isIntegerObject: foo  => interpreterProxy->isIntegerObject(foo)

and internally isIntegerOop() can be just a macro where it does (foo&1)..

what important to me is that C sources should as close as possible
reflect an original expression written in slang.

if developer wrote 'foo & 1' in slang code, then, and only then it
should generate C code which uses same.

> That would at least make sense, agreed.
>
> I'd have expected both constructs to result in the same generated code, so they could be used interchangeably.
>
> - Bert -
>
>> when you looking at C source it is important to not lose track of what
>> was written in slang.
>> and in this regard, expression
>>
>>  interpreterProxy->isIntegerObject(foo)
>>
>> is preferable because you know exactly what's going on, in contrast to:
>>
>>     (foo & 1)
>>
>> where you can wonder, whether same expression is written in slang.. or
>> it is translation artefact.
>> We should avoid ambiguous stuff.. especially since you can always use macros
>> so it won't affect any speed whatsoever.
>>
>>> - Bert -
>>>
>>
>> --
>> Best regards,
>> Igor Stasenko.
>



--
Best regards,
Igor Stasenko.
Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

Bert Freudenberg


On 2013-03-15, at 13:50, Igor Stasenko <[hidden email]> wrote:

>
> On 15 March 2013 13:43, Bert Freudenberg <[hidden email]> wrote:
>>
>>
>> On 2013-03-14, at 21:18, Igor Stasenko <[hidden email]> wrote:
>>
>>>
>>> On 14 March 2013 19:27, Bert Freudenberg <[hidden email]> wrote:
>>>>
>>>> Slang:  foo isIntegerOop
>>>> C:      interpreterProxy->isIntegerObject(foo)
>>>>
>>>> Slang:  interpreterProxy isIntegerObject: foo
>>>> C:      (foo & 1)
>>>>
>>>> SmartSyntaxInterpreterPlugin: y u no smart?
>>>>
>>> i'd say completely opposite.
>>
>>
>> You mean, "foo isIntegerOop" should generate "(foo & 1)", and "interpreterProxy isIntegerObject: foo" should generate "interpreterProxy->isIntegerObject(foo)", yes?
>>
>
> no i meant, both should generate
>
> foo isIntegerOop => isIntegerOop(foo)
> interpreterProxy isIntegerObject: foo  => interpreterProxy->isIntegerObject(foo)
>
> and internally isIntegerOop() can be just a macro where it does (foo&1)..

Okay, so not "completely opposite" :)

- Bert -

> what important to me is that C sources should as close as possible
> reflect an original expression written in slang.
>
> if developer wrote 'foo & 1' in slang code, then, and only then it
> should generate C code which uses same.
>
>> That would at least make sense, agreed.
>>
>> I'd have expected both constructs to result in the same generated code, so they could be used interchangeably.
>>
>> - Bert -
>>
>>> when you looking at C source it is important to not lose track of what
>>> was written in slang.
>>> and in this regard, expression
>>>
>>> interpreterProxy->isIntegerObject(foo)
>>>
>>> is preferable because you know exactly what's going on, in contrast to:
>>>
>>>    (foo & 1)
>>>
>>> where you can wonder, whether same expression is written in slang.. or
>>> it is translation artefact.
>>> We should avoid ambiguous stuff.. especially since you can always use macros
>>> so it won't affect any speed whatsoever.
>>>
>>>> - Bert -
>>>>
>>>
>>> --
>>> Best regards,
>>> Igor Stasenko.
>>
>
>
>
> --
> Best regards,
> Igor Stasenko.



Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

Igor Stasenko
 
On 15 March 2013 14:34, Bert Freudenberg <[hidden email]> wrote:

>
>
> On 2013-03-15, at 13:50, Igor Stasenko <[hidden email]> wrote:
>
>>
>> On 15 March 2013 13:43, Bert Freudenberg <[hidden email]> wrote:
>>>
>>>
>>> On 2013-03-14, at 21:18, Igor Stasenko <[hidden email]> wrote:
>>>
>>>>
>>>> On 14 March 2013 19:27, Bert Freudenberg <[hidden email]> wrote:
>>>>>
>>>>> Slang:  foo isIntegerOop
>>>>> C:      interpreterProxy->isIntegerObject(foo)
>>>>>
>>>>> Slang:  interpreterProxy isIntegerObject: foo
>>>>> C:      (foo & 1)
>>>>>
>>>>> SmartSyntaxInterpreterPlugin: y u no smart?
>>>>>
>>>> i'd say completely opposite.
>>>
>>>
>>> You mean, "foo isIntegerOop" should generate "(foo & 1)", and "interpreterProxy isIntegerObject: foo" should generate "interpreterProxy->isIntegerObject(foo)", yes?
>>>
>>
>> no i meant, both should generate
>>
>> foo isIntegerOop => isIntegerOop(foo)
>> interpreterProxy isIntegerObject: foo  => interpreterProxy->isIntegerObject(foo)
>>
>> and internally isIntegerOop() can be just a macro where it does (foo&1)..
>
> Okay, so not "completely opposite" :)

no it is.. you said that smart syntax plugin is not so smart by not replacing
foo isIntegerOop with (foo & 1)

and i said , that in contrary, it is basic generator is not smart by
replacing foo isIntegerOop with (foo & 1).

:)

>
> - Bert -
>
>> what important to me is that C sources should as close as possible
>> reflect an original expression written in slang.
>>
>> if developer wrote 'foo & 1' in slang code, then, and only then it
>> should generate C code which uses same.
>>
>>> That would at least make sense, agreed.
>>>
>>> I'd have expected both constructs to result in the same generated code, so they could be used interchangeably.
>>>
>>> - Bert -
>>>
>>>> when you looking at C source it is important to not lose track of what
>>>> was written in slang.
>>>> and in this regard, expression
>>>>
>>>> interpreterProxy->isIntegerObject(foo)
>>>>
>>>> is preferable because you know exactly what's going on, in contrast to:
>>>>
>>>>    (foo & 1)
>>>>
>>>> where you can wonder, whether same expression is written in slang.. or
>>>> it is translation artefact.
>>>> We should avoid ambiguous stuff.. especially since you can always use macros
>>>> so it won't affect any speed whatsoever.
>>>>
>>>>> - Bert -
>>>>>
>>>>
>>>> --
>>>> Best regards,
>>>> Igor Stasenko.
>>>
>>
>>
>>
>> --
>> Best regards,
>> Igor Stasenko.
>
>
>



--
Best regards,
Igor Stasenko.
Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

Bert Freudenberg

On 2013-03-15, at 15:53, Igor Stasenko <[hidden email]> wrote:

>>>>> On 14 March 2013 19:27, Bert Freudenberg <[hidden email]> wrote:
>>>>>>
>>>>>> Slang:  foo isIntegerOop
>>>>>> C:      interpreterProxy->isIntegerObject(foo)
>>>>>>
>>>>>> Slang:  interpreterProxy isIntegerObject: foo
>>>>>> C:      (foo & 1)
>>>>>>
>>>>>> SmartSyntaxInterpreterPlugin: y u no smart?
>>>>>>
> you said that smart syntax plugin is not so smart by not replacing
> foo isIntegerOop with (foo & 1)


Did I? Don't think so - see above. I just pointed out what it is doing is surprising, not what would be right.

Anyway, Eliot made a good argument about what the right translation should be.

- Bert -

Reply | Threaded
Open this post in threaded view
|

Re: Translation weirdness

Igor Stasenko
 
On 15 March 2013 16:31, Bert Freudenberg <[hidden email]> wrote:

>
> On 2013-03-15, at 15:53, Igor Stasenko <[hidden email]> wrote:
>
>>>>>> On 14 March 2013 19:27, Bert Freudenberg <[hidden email]> wrote:
>>>>>>>
>>>>>>> Slang:  foo isIntegerOop
>>>>>>> C:      interpreterProxy->isIntegerObject(foo)
>>>>>>>
>>>>>>> Slang:  interpreterProxy isIntegerObject: foo
>>>>>>> C:      (foo & 1)
>>>>>>>
>>>>>>> SmartSyntaxInterpreterPlugin: y u no smart?
>>>>>>>
>> you said that smart syntax plugin is not so smart by not replacing
>> foo isIntegerOop with (foo & 1)
>
>
> Did I? Don't think so - see above. I just pointed out what it is doing is surprising, not what would be right.
>
> Anyway, Eliot made a good argument about what the right translation should be.
>
Nevermind :)

At least we agree that (foo & 1) is not good :)

> - Bert -
>



--
Best regards,
Igor Stasenko.