Create variable lazarus / 9-Editor ---------------------------------------------------------------------- LazaruX · 2009-03-03 21:03 Hi, In C languages, like for example in C#.NET, you can create any variable whereever in the code. Code: [Select]{         string str = "The pascal language is better than me";         if (str != "")              {                    int number = 100;              } } I actually didn't like this approach and preferred the Pascal one, but now I have got a question: Is this possible in Pascal? Or is it only possible to define variables before? ---------------------------------------------------------------------- Leledumbo · 2009-03-04 04:21 QuoteIs this possible in Pascal?No, it's not. Except if you use GPC (they call it "declaration as statement") which is OK since the backend compiler is the same as GCC. QuoteOr is it only possible to define variables before?It's the only way. CMIIW, with this the compiler can do better register allocation since all variables that will be used are known. One thing I know for sure is that this really helps the parser because dealing with symbol table (i.e. writing what symbols may be used) can be done only at the beginning, no need to do it when parsing statements. ---------------------------------------------------------------------- LazaruX · 2009-05-01 19:32 But so if I understand good, in C languages its easier to have memory leaks than in Pascal correct??? ---------------------------------------------------------------------- Leledumbo · 2009-05-04 02:03 No need to ensure that anymore. I'll say it YES! (plus: it can't be easily detected)