January 12, 2009
Miles wrote:
> ---------
> 	int func1() { return 1; }
> 
> 	auto a = func1;		// 'a' is a pointer to func1
> 	auto b = &func1;	// ERROR, or deprecated way of above
> 	auto c = func1();	// calls func1 and returns int 1
> 
> 	int function() func2 = func1;
> 
> 	auto d = func2;		// 'd' is a pointer to func1
> 	auto e = &func2;	// 'e' is a ptr to ptr to func
> 	auto f = func2();	// calls func1 and returns int 1
> ---------

So you consider functions to be a reference type, since the value of a function is not terribly useful. You want the declarations "void foo() {}" and "invariant(void function()) foo = {};" to be equivalent.

This can work, provided you get properties. Otherwise you're back to Javaland.
January 13, 2009
Hello Nick,

> "John Reimer" <terminal.node@gmail.com> wrote in message
> news:28b70f8c119bd8cb4246de86cc80@news.digitalmars.com...
> 
>> Hello Nick,
>> 
>>> "John Reimer" <terminal.node@gmail.com> wrote in message
>>> news:28b70f8c119528cb42154f5d14e0@news.digitalmars.com...
>>> 
>>>> Hello Nick,
>>>> 
>>>>> But, of course, adjectives (just like "direct/indirect objects")
>>>>> are themselves nouns.
>>>>> 
>>>> Umm... May I make a little correction here?
>>>> Adjectives are not nouns.  They are used to /describe/ nouns.
>>>> -JJR
>>> Maybe there's examples I'm not thinking of, and I'm certainly no
>>> natural language expert, but consider these:
>>> 
>>> "red"
>>> "ball"
>>> "red ball"
>>> By themselves, "red" and "ball" are both nouns. Stick the noun "red"
>>> in front of ball and "red" becomes an adjectve. (FWIW,
>>> "dictionary.reference.com" lists "red" as both a noun and an
>>> adjective). The only adjectives I can think of at the moment (in my
>>> admittedly quite tired state) are words that are ordinarly nouns on
>>> their own.  I would think that the distinguishing charactaristic of
>>> an
>>> adjective vs noun would be the context in which it's used.
>>> Maybe I am mixed up though, it's not really an area of expertise for
>>> me.
>>> 
>> No problem.  I am not saying a word can't be /used/ as an adjective
>> and noun in different contexts.  I'm just saying that they can't be
>> an adjective and noun at the same time as your first post suggested.
>> 
>> Grammatically, adjectives are not nouns (ever), even if the words
>> themselves can be used as either in independent contexts; they just
>> modify nouns.  Like Jarett mentions, the fact that words that are
>> adjectives in one context can shapeshift to another part of speech
>> (the noun) in another, is immaterial to the definition: you just have
>> to recognize when it happens and realize the change that has occurred
>> in the part of speech.
>> 
> I guess that's a difference between natural languages and
> oop-languages then. A member variable of an object typically
> /describes an attribute/ of the object, and thus makes it comparable
> to the notion of "adjective", but in an oop-language (and apperently
> unlike a natural language) that member object is itself either another
> object or a primitive.
> 


Yes, although natural languages and programming languages might share some similarities, natural langauges are going to be much more complex (even though both consist of grammars and alphabets). I know there's a whole science and theory of natural language analysis of which I'm mostly ignorant beyond a basic introduction.  Much of the research of computer languages and compilers seems to have borrowed from the study of natural languages (see Noam Chomsky). I need to study it more myself.

Also I just want to make clear that my explanation above was meant only to emphasize English grammar rules.  I don't know enough about other natural langauges to make the statement universally applicable. There are some very "unusual" natural languages out there that will have a very different grammar such that, I suppose, they would seem to break the rules familiar to an English speaker.  But, of course, a different language is not subject to the rules of the English grammar, so it should be no surprise.

-JJR


January 13, 2009
Hello Christopher,

> John Reimer wrote:
> 
>> Hello Nick,
>> 
>>> But, of course, adjectives (just like "direct/indirect objects") are
>>> themselves nouns.
>>> 
>> Umm... May I make a little correction here? Adjectives are not nouns.
>> They are used to /describe/ nouns.
>> 
>> -JJR
>> 
> No programming language that I know distinguishes parts of an object
> (the hand of a body) from attributes of an object (the color of a
> ball). I think that's what he was getting at.
> 



Yes, I was not critiquing his commentary on programming languages: it would have been dangerous for me to do so :).  I was being (perhaps overly) nit-picky about his statement that incorrectly paralleled English grammar to the topic of discussion.

-JJR


January 13, 2009
Miles wrote:
> dsimcha wrote:
>> I figure the vast majority of cases are going to be primitive types anyhow (mostly
>> ints),
> 
> Yes, this is very true.
> 
>> and if someone defines operator overloads such that foo += 1 produces
>> totally different observable behavior than foo = foo + 1, that's just too
>> ridiculously bad a design to even take seriously.
> 
> Sure. It is bad coding style, it is ugly and the programmer who does
> this should be called for a meeting with his boss. But there are still
> ways to have sane behavior, even in such situations. See below.
> 
>> What do you think?  Is it worth
>> ignoring a few hard cases in exchange for solving most cases simply and elegantly
>> and without adding any new constructs?
> 
> Instead, I think it is more sane to use temporaries.
> 
> ----------
> 	{
> 	  auto tmp = __get_foo();
> 	  tmp += 1;
> 	  __set_foo(foo);
> 	}
> ----------
> 
> It is the safest this way, principle of least surprise. If the caller
> does foo += 1, it will get that; if it does foo = foo + 1, it will still
> get that; if it does foo.call(), again, the behavior is still sane.
> 
> We must first attack the semantics. This have sane semantics. Then let
> the compiler optimize that as far as possible. The compiler inlines the
> getter and setter calls, then optimizes away the temporary, etc.

Or the compiler could prevent properties from returning mutable structs?

class MyClass {

  private MyStruct _a;
  private MyStruct _b;

  public property a {
    const get { return _a; } // legal
  }

  public property a {
    get { return _b; } // compile-time error
  }
}

On the flip-side, the compiler could intervene at the call site, preventing modification of structs when directly accessed via a property invocation. Though I think the first solution is better.

--benji
January 13, 2009
Nick Sabalausky wrote:
> "John Reimer" <terminal.node@gmail.com> wrote in message news:28b70f8c119528cb42154f5d14e0@news.digitalmars.com...
>> Hello Nick,
>>
>>> But, of course, adjectives (just like "direct/indirect objects") are
>>> themselves nouns.
>>>
>>
>> Umm... May I make a little correction here?
>> Adjectives are not nouns.  They are used to /describe/ nouns.
>>
>> -JJR
>>
> 
> Maybe there's examples I'm not thinking of, and I'm certainly no natural language expert, but consider these:
> 
> "red"
> "ball"
> "red ball"
> 
> By themselves, "red" and "ball" are both nouns. Stick the noun "red" in front of ball and "red" becomes an adjectve. (FWIW, "dictionary.reference.com" lists "red" as both a noun and an adjective). The only adjectives I can think of at the moment (in my admittedly quite tired state) are words that are ordinarly nouns on their own.  I would think that the distinguishing charactaristic of an adjective vs noun would be the context in which it's used.
> 
> Maybe I am mixed up though, it's not really an area of expertise for me. 

Incidentally...

I used to do a lot of work in natural language processing, and our parsing heuristics were built to handle a lot of adjective/noun ambiguity.

For example, in the phrase "car dealership", the word "car" is an adjective that modifies "dealership".

For the most part, you can treat adjectives and nouns as being functionally identical, and the final word in a sequence of adjectives and nouns becomes the primary noun of the noun-phrase.

--benji
January 13, 2009
Hello Benji,

> Nick Sabalausky wrote:
> 
>> "John Reimer" <terminal.node@gmail.com> wrote in message
>> news:28b70f8c119528cb42154f5d14e0@news.digitalmars.com...
>> 
>>> Hello Nick,
>>> 
>>>> But, of course, adjectives (just like "direct/indirect objects")
>>>> are themselves nouns.
>>>> 
>>> Umm... May I make a little correction here?
>>> Adjectives are not nouns.  They are used to /describe/ nouns.
>>> -JJR
>>> 
>> Maybe there's examples I'm not thinking of, and I'm certainly no
>> natural language expert, but consider these:
>> 
>> "red"
>> "ball"
>> "red ball"
>> By themselves, "red" and "ball" are both nouns. Stick the noun "red"
>> in front of ball and "red" becomes an adjectve. (FWIW,
>> "dictionary.reference.com" lists "red" as both a noun and an
>> adjective). The only adjectives I can think of at the moment (in my
>> admittedly quite tired state) are words that are ordinarly nouns on
>> their own.  I would think that the distinguishing charactaristic of
>> an adjective vs noun would be the context in which it's used.
>> 
>> Maybe I am mixed up though, it's not really an area of expertise for
>> me.
>> 
> Incidentally...
> 
> I used to do a lot of work in natural language processing, and our
> parsing heuristics were built to handle a lot of adjective/noun
> ambiguity.
> 
> For example, in the phrase "car dealership", the word "car" is an
> adjective that modifies "dealership".
> 
> For the most part, you can treat adjectives and nouns as being
> functionally identical, and the final word in a sequence of adjectives
> and nouns becomes the primary noun of the noun-phrase.
> 
> --benji
> 


Interesting.  There is certainly room to play here.  I never thought of this potential ambiguity of "nouns" and "adjectives" in a noun phrase.

Thanks for the info.  I'll look into this a little more.

I guess Nick wasn't /that/ far of track. :)

-JJR


January 13, 2009
Benji Smith wrote:
> Nick Sabalausky wrote:
>> "John Reimer" <terminal.node@gmail.com> wrote in message news:28b70f8c119528cb42154f5d14e0@news.digitalmars.com...
>>> Hello Nick,
>>>
>>>> But, of course, adjectives (just like "direct/indirect objects") are
>>>> themselves nouns.
>>>>
>>>
>>> Umm... May I make a little correction here?
>>> Adjectives are not nouns.  They are used to /describe/ nouns.
>>>
>>> -JJR
>>>
>>
>> Maybe there's examples I'm not thinking of, and I'm certainly no natural language expert, but consider these:
>>
>> "red"
>> "ball"
>> "red ball"
>>
>> By themselves, "red" and "ball" are both nouns. Stick the noun "red" in front of ball and "red" becomes an adjectve. (FWIW, "dictionary.reference.com" lists "red" as both a noun and an adjective). The only adjectives I can think of at the moment (in my admittedly quite tired state) are words that are ordinarly nouns on their own.  I would think that the distinguishing charactaristic of an adjective vs noun would be the context in which it's used.
>>
>> Maybe I am mixed up though, it's not really an area of expertise for me. 
> 
> Incidentally...
> 
> I used to do a lot of work in natural language processing, and our parsing heuristics were built to handle a lot of adjective/noun ambiguity.
> 
> For example, in the phrase "car dealership", the word "car" is an adjective that modifies "dealership".

It's a genitive phrase, not an adjective. You couldn't say "That dealership is car", for instance, but you could say "That is a dealership of cars."

> For the most part, you can treat adjectives and nouns as being functionally identical, and the final word in a sequence of adjectives and nouns becomes the primary noun of the noun-phrase.

No, you can't: "I gave the postman chlamydia." What is postman chlamydia?

> --benji
January 13, 2009
Hello Christopher,

> Benji Smith wrote:
> 
>> Nick Sabalausky wrote:
>> 
>>> "John Reimer" <terminal.node@gmail.com> wrote in message
>>> news:28b70f8c119528cb42154f5d14e0@news.digitalmars.com...
>>> 
>>>> Hello Nick,
>>>> 
>>>>> But, of course, adjectives (just like "direct/indirect objects")
>>>>> are themselves nouns.
>>>>> 
>>>> Umm... May I make a little correction here?
>>>> Adjectives are not nouns.  They are used to /describe/ nouns.
>>>> -JJR
>>>> 
>>> Maybe there's examples I'm not thinking of, and I'm certainly no
>>> natural language expert, but consider these:
>>> 
>>> "red"
>>> "ball"
>>> "red ball"
>>> By themselves, "red" and "ball" are both nouns. Stick the noun "red"
>>> in front of ball and "red" becomes an adjectve. (FWIW,
>>> "dictionary.reference.com" lists "red" as both a noun and an
>>> adjective). The only adjectives I can think of at the moment (in my
>>> admittedly quite tired state) are words that are ordinarly nouns on
>>> their own.  I would think that the distinguishing charactaristic of
>>> an adjective vs noun would be the context in which it's used.
>>> 
>>> Maybe I am mixed up though, it's not really an area of expertise for
>>> me.
>>> 
>> Incidentally...
>> 
>> I used to do a lot of work in natural language processing, and our
>> parsing heuristics were built to handle a lot of adjective/noun
>> ambiguity.
>> 
>> For example, in the phrase "car dealership", the word "car" is an
>> adjective that modifies "dealership".
>> 
> It's a genitive phrase, not an adjective. You couldn't say "That
> dealership is car", for instance, but you could say "That is a
> dealership of cars."
> 
>> For the most part, you can treat adjectives and nouns as being
>> functionally identical, and the final word in a sequence of
>> adjectives and nouns becomes the primary noun of the noun-phrase.
>> 
> No, you can't: "I gave the postman chlamydia." What is postman
> chlamydia?
> 
>> --benji
>> 


The reason I conceeded a little on this one is because of http://en.wikipedia.org/wiki/Noun_phrase.

I'm not sure if wikipedia can be absolutely trusted... but this is beyond my grammatical knowledge to argue absolutely.  In a sentence diagram, I would assume that adjectives would have to be distinctly positioned.

In Benji's example, I assume practicality of implementation is what allows adjectives/nouns to be treated similarly, not necessarily strict adherence to grammatical rules.

Just guessing...

-JJR


January 13, 2009
Christopher Wright wrote:
> So you consider functions to be a reference type, since the value of a
> function is not terribly useful. You want the declarations "void foo()
> {}" and "invariant(void function()) foo = {};" to be equivalent.

Yes, almost equivalent.
1 2 3 4 5 6 7 8 9 10 11
Next ›   Last »