Board index » delphi » why doesn't delphi support macros?

why doesn't delphi support macros?

hehe, anybody know the answer to this?
 

Re:why doesn't delphi support macros?


It does.  Depending on what you're asking.

Tools|Environment Options

Go to the Code Insight tab, and there are some templates.

To use templates (macros) hit Control J.

This assumes you mean you want macros to help you code...

Quote
Gordy wrote:
> hehe, anybody know the answer to this?

Re:why doesn't delphi support macros?


But not even an option.. I would gladly.. I mean GLADLY give up that speedy
compilation for macros. Is there any 3rd party tool that maybe extends the
delphi environment with macro support?

Re:why doesn't delphi support macros?


Quote
On Mon, 16 Aug 1999 19:29:58 -0700, "Gordy" <gf...@jps.net> wrote:
>hehe, anybody know the answer to this?

It's largely historical, but one of the primary reasons is that
including macros means having a preprocessor, which in turn means that
compilation would be significantly slower.

-Steve

Re:why doesn't delphi support macros?


Why not switch to C++ Builder?  It is very similar, the IDE is built
around the Delphi IDE, it uses the same VCL and of course C++ supports
macros
Quote
Gordy wrote:

> But not even an option.. I would gladly.. I mean GLADLY give up that speedy
> compilation for macros. Is there any 3rd party tool that maybe extends the
> delphi environment with macro support?

Re:why doesn't delphi support macros?


Quote
In article <7panld$qj...@forums.borland.com>, Gordy wrote:
> I would gladly.. I mean GLADLY give up that speedy
> compilation for macros.

I suspect that you are in a minority.

Another downside, IMO, is that it makes reading other people's code far
more difficult, thus introducing a potential maintenance overhead.

 Mike Orriss (TeamB)
 (Unless stated otherwise, my replies relate to Delphi 4.03)
 (Unsolicited e-mail replies will most likely be ignored)

Re:why doesn't delphi support macros?


I wasn't aware that builder supported macros.. but if builder can have
macros, why can't delphi have macros???? Does delphi compile faster than
builder?  Seriously.. I dont know why this isn't a bigger issue.. certain
things that are defined as macros in the win32 sdk are implemented by delphi
as functions.. even when delphi avoids creating a stack the performance is
just shot to hell.

for example.. I have a function that I use aaallll the time  trimint(byte,
min, max).. of coarse you give it a byte and it makes sure its within
min/max bounds..  in a huge loop (width*height on some bitmap).. I get about
a 30% speed increase when I copy the code from that function and put it in
the loop, just eliminating function overhead.

It really just seems like a pretty big thing to leave out of delphi. its
like putting a restrictor plate on a v12 engine eh?
-Gordy

Re:why doesn't delphi support macros?


Quote
> Does delphi compile faster than builder?

Yes.

- Rick

Re:why doesn't delphi support macros?


Interestingly, C++ supports macros, but many people say, "Don't use macros
anymore."  This is because you can declare methods to be 'inline', meaning that
they will be expanded by the compiler at build time.  Using the C++ inline
keyword makes for much more readable code and retains the performance gain that
you get with small macros.

Here's an idea for you.  Notepad makes for a good preprocessor.  Use your
"macro" all through your code, then do a search and replace of your "macro" with
the actual code you want to run.  Now just compile your code normally.

--

Mark Lauter
Independent Contractor
Find a few Free Delphi and C++ Builder components here...
http://home.tampabay.rr.com/marknmarilynn/

Quote
Gordy <gf...@jps.net> wrote in message news:7pb18c$rak6@forums.borland.com...

I wasn't aware that builder supported macros.. but if builder can have
macros, why can't delphi have macros???? Does delphi compile faster than
builder?  Seriously.. I dont know why this isn't a bigger issue.. certain
things that are defined as macros in the win32 sdk are implemented by delphi
as functions.. even when delphi avoids creating a stack the performance is
just shot to hell.

for example.. I have a function that I use aaallll the time  trimint(byte,
min, max).. of coarse you give it a byte and it makes sure its within
min/max bounds..  in a huge loop (width*height on some bitmap).. I get about
a 30% speed increase when I copy the code from that function and put it in
the loop, just eliminating function overhead.

It really just seems like a pretty big thing to leave out of delphi. its
like putting a restrictor plate on a v12 engine eh?
-Gordy

Re:why doesn't delphi support macros?


Quote
On Mon, 16 Aug 1999 19:29:58 -0700, "Gordy" <gf...@jps.net> wrote:
>hehe, anybody know the answer to this?

I'm assuming you mean compiler macros rather than IDE macros (to
automate tasks in the IDE).  I can't answer the IDE question, except
that it seems to me there is at least some support there.

Assuming you mean compiler macros like C's #define, it's because they
are a bad way of doing things.  They open up lots of ways to break
strong typing, which is one of the major design features of pascal.
You get type errors not related to what you see, but what the compiler
sees.  This makes code harder to read.

A more serious problem is that they look like functions but don't get
handled like functions.  For instance (I assume you understand this or
you wouldn't be asking the question, but others may not), in C (or
C++) I can define a macro
#define square(x) (x*x)

If in my code, I do something like
  square(inc(x));
 which looks just fine (increment x, and square it) what actually gets
generated is
  (inc(x) * inc(x))
because it's doing a text substituion of x for whatever got passed in.
This is quite different than the indended
 inc(x); x*x;
and very difficutl to spot.

Both of these situations are enathema in Pascal, hence are not
supported in Delphi.  My day job has me programming exclusively in
C++, and I do not use macros there.  I use templates and inline
functions instead.  These are what I'd *really* like to see Delphi
support.

Re:why doesn't delphi support macros?


Quote
>Here's an idea for you.  Notepad makes for a good preprocessor.  Use your
>"macro" all through your code, then do a search and replace of your "macro"
with
>the actual code you want to run.  Now just compile your code normally.

thats sorta the point of macros and I wonder why must we do this crazy
stuff, when borland could just implement the "inline" calling process.
inline has been a reserved word in delphi since v2, but hasn't been
implemented yet.. after 3 versions!  Why can't delphi have an option for a
"find & replace" the inline calls just before compilation.

Re:why doesn't delphi support macros?


Yeah, I agree, this doesn't sound like such a hard thing to do.  But then, I've
never written a compiler or preprocessor, so I don't really have any idea what
I'm talking about.

--

Mark Lauter
Independent Contractor
Find a few Free Delphi and C++ Builder components here...
http://home.tampabay.rr.com/marknmarilynn/

Quote
Gordy <gf...@jps.net> wrote in message news:7pcdq0$ss915@forums.borland.com...
>Here's an idea for you.  Notepad makes for a good preprocessor.  Use your
>"macro" all through your code, then do a search and replace of your "macro"
with
>the actual code you want to run.  Now just compile your code normally.

thats sorta the point of macros and I wonder why must we do this crazy
stuff, when borland could just implement the "inline" calling process.
inline has been a reserved word in delphi since v2, but hasn't been
implemented yet.. after 3 versions!  Why can't delphi have an option for a
"find & replace" the inline calls just before compilation.

Re:why doesn't delphi support macros?


Yes, CONSIDERABLY faster!  I have just started using Delphi, because my
new contract requires it.  I'm more comfortable in C++, so I prefer it,
but the speed at which Delphi compiles is certainly a bonus.

If builder can have macros, why can't delphi?  Well, builder uses C++ -
macros have always been part of C and C++ (well, I shouldn't say always,
'cause C was around for longer than I've been programming.)  

Quote
Gordy wrote:

> I wasn't aware that builder supported macros.. but if builder can have
> macros, why can't delphi have macros???? Does delphi compile faster than
> builder?  Seriously.. I dont know why this isn't a bigger issue.. certain
> things that are defined as macros in the win32 sdk are implemented by delphi
> as functions.. even when delphi avoids creating a stack the performance is
> just shot to hell.

> for example.. I have a function that I use aaallll the time  trimint(byte,
> min, max).. of coarse you give it a byte and it makes sure its within
> min/max bounds..  in a huge loop (width*height on some bitmap).. I get about
> a 30% speed increase when I copy the code from that function and put it in
> the loop, just eliminating function overhead.

> It really just seems like a pretty big thing to leave out of delphi. its
> like putting a restrictor plate on a v12 engine eh?
> -Gordy

Re:why doesn't delphi support macros?


Quote
Mark Lauter wrote:

> Yeah, I agree, this doesn't sound like such a hard thing to do.  But then, I've
> never written a compiler or preprocessor, so I don't really have any idea what
> I'm talking about.

They used to have it (an inline directive). The bad part of it
was that you had to use machine code numonics.

Joe
--
Joe C. Hecht
http://home1.gte.net/joehecht/index.htm

Re:why doesn't delphi support macros?


<<
They used to have it (an inline directive). The bad part of it
was that you had to use machine code numonics.

Quote

What do you mean by "machine code numonics"?

--

Mark Lauter
Independent Contractor
Find a few Free Delphi and C++ Builder components here...
http://home.tampabay.rr.com/marknmarilynn/

Go to page: [1] [2]

Other Threads