With C# inside of Visual Studio, I have very good IDE support for top-
down design. If I use an undeclared method, it is displayed in red,
with a tooltip saying "Cannot resolve symbol '[symbol name]'". A
context menu provides me "generate > method stub", which will do what
it says, and add parameter names based on how I use it, and use type
inference.
E.g., if what I typed was "string name = GetName( enumType, value );"
it can generate "private string GetName( Type enumType, MyEnum value)
{ throw NotImplementedException(); }"
It's an oft-used feature for me, but in particular, that's an IDE
feature, not a language feature.
More importantly, I haven't had to deal with declaration order being a
limitation in a language since C++. It feels... backwards to me, if
it's by design.
I'm aware that a lot of the problems can be reduced with IDE support,
indexing symbols and such, but I haven't seen it yet. Fortunately
parsing clojure seems very straightforward, so that may be a feasible
option.
Secondly, thanks to everyone for pointing out that you _can_ use
"declare". It's a solution for now.
On Feb 23, 1:20 pm, Alessio Stalla <[email protected]> wrote:
> On 23 Feb, 01:28, Mark Engelberg <[email protected]> wrote:
>
> > I'm not crazy about this behavior either, but my understanding is that
> > this is an intentional design decision that is a direct consequence of
> > two things:
> > 1. In Clojure IDEs, people want to be able to feed the compiler
> > single functions and expressions. You don't need to compile the
> > entire file all at once; this can be useful for making small
> > modifications to a running system. For consistency, compiling the
> > entire file is just like feeding the functions into the compiler one
> > by one. There's no special "lookahead" for compiling a file in its
> > entirety.
>
> That's the same for Common Lisp.
>
> > 2. Without lookahead, declarations are the only way to allow the
> > compiler to give an intelligent error message if you accidentally
> > refer to a function name that does not exist. People want good error
> > messages.
>
> Doesn't make sense. If the compiler can recognize that a function is
> not defined (and it can, since it signals an error), then it can
> signal a meaningful error or even better a warning (e.g., "call to
> unknown function FOO"). To have the function declaration beforehand is
> necessary only when you want to do some optimizations based on the
> type of the function or other properties (e.g. if the function is
> declared inline).
> I don't know why Clojure requires declare, but certainly it looks like
> an unnecessary limitation from someone coming from Common Lisp.
>
> Cheers,
> Alessio
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en