Re: Patch to try out: floating point
Tony Mechelynck wrote: On 09/04/08 17:30, Bram Moolenaar wrote: Tony Mechelynck wrote: [...] Oh, oh.. it had started working (and1.0e256 multiplied by itself gives inf, which is correct), but :echo1.0e308 crashes gvim (on Linux i686) with SIGSEGV. Easy to reproduce. Turns out that this line causes it: sprintf(tmp, format, f); Here format is %f and f is your value 1e+308. The result is an awful long string of numbers. I suppose it's about 308 digits. How big does tmp need to be to hold any result here? I don't think %f has a way of specifying a maximal field width. [...] I suggest a third floating-point format (%g maybe, or something else if that is already taken) which would mean either %f or %e depending on the size of the exponent similar, IIRC, to the number output formats available in FORTRAN and/or BASIC. That format would be implicit when :echoing a floating-point number. (Yes, I know, Vim is neither FORTRAN nor BASIC, but I feel this kind of thing would be better than crashing or even than giving an error.) +1. Ben. IIRC, in FORTRAN, the G output format would give (for different values output under a single format) results like: -1.234567E-123 (for a small number) 2.25 (with spaces to the same width) 342.5682 (with spaces for a large number but not too large) 6.02E+023 (for an even bigger number) NAN(a special case) -INF (another special case) (this from what [I think that] I remember from the time I used FORTRAN on computers whose printers had no lowercase letters). --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
RE: Patch to try out: floating point
Bill McCarthy wrote: I want +float - how do I make that happen? One simple method is to add the following line to src/feature.h #define FEAT_FLOAT You could probably do that anywhere, but just after the section with #if relating to FEAT_FLOAT is probably a good place. I would welcome a less crude suggestion. John --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Anoop Thomas Mathew wrote: What's your opinion about a project in VIMas an on the fly code checker. I really think you should consider composing a new email thread instead of piggy backing on another email thread; especially one that has nothing to do with your topic and already is full of entries. Translated: you're missing your target audience. Steps - i.That is VIM text to a temporary file. ii.Compile it with a compiler.(Either use an external compiler ( preferred by Mr. Moolenaar) or to write an independent parser plug-in within VIM) iii.Then re-parse the error messages. This is my proposed idea for Google Summer of Code 2008. Is there any mistake or faults.Please guide me out. If you want speed, you need to do the syntax checking yourself, which probably means a LALR parser (ie. an equivalent of yacc). If speed is of little concern, your approach might work, although o/s's that lack decent multi-tasking would make the use of this unpleasant. When I start coding, I often use a template, so I start off with a valid C/C++ program. However, there are plenty of times that the code is in-development, and not ready for compiling. I think I'd find this annoying, but I'm willing to be pleasantly surprised. I have vim-commands that compile and check code; the checking (called :Chk for some reason!) uses Vim's quickfix so I can relatively cleanly handle compiler errors/warnings without leaving the editor. However, there are projects that I work with that :Chk doesn't work correctly for (largely due to the need for compiler options, special libraries, etc, and the knowledge to compile correctly is embedded in a Makefile). Thus you undoubtedly will have some gotchas in coding this that you're not currently aware of. Regards, Chip Campbell --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Bram Moolenaar wrote: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 That is because . is the concatenation operator, and numbers are automatically converted to strings. I considered a few alternatives: 123,456 used for function arguments float(123,456)too verbose #123.456has a meaning after == and != $123.456confusion with $ENV The best I could think of was 123.456. It's a bit obscure, you need to get used to it. But it works. echo 123.456e-3 0.123456 Feel free to suggest something better, but make sure it doesn't already mean something in any context in Vim script. Have fun with the patch! snip Thank you, Bram! I've occasionally wishes for some floating point support (such as for Mines in computing the winning percentage). Might be able to handle that LargeFile stuff better (I'll have to think about that), too. Regards, Chip Campbell --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Mikolaj Machowski wrote: Dnia Wednesday 09 of April 2008, Tony Mechelynck napisa³: runtime/doc/eval.txt, line 40 is unchanged, there is: There are five types of variables: There should be: There are six types of variables: One more addition to eval.txt, line 5218 (:help type()): :if type(myvar) == type({}) Add after that line: :if type(myvar) == type(0) Thanks! -- A cow comes flying over the battlements, lowing aggressively. The cow lands on GALAHAD'S PAGE, squashing him completely. Monty Python and the Holy Grail PYTHON (MONTY) PICTURES LTD /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\download, build and distribute -- http://www.A-A-P.org/// \\\help me help AIDS victims -- http://ICCF-Holland.org/// --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 09/04/08 17:30, Bram Moolenaar wrote: Tony Mechelynck wrote: [...] Oh, oh.. it had started working (and1.0e256 multiplied by itself gives inf, which is correct), but :echo1.0e308 crashes gvim (on Linux i686) with SIGSEGV. Easy to reproduce. Turns out that this line causes it: sprintf(tmp, format, f); Here format is %f and f is your value 1e+308. The result is an awful long string of numbers. I suppose it's about 308 digits. How big does tmp need to be to hold any result here? I don't think %f has a way of specifying a maximal field width. [...] I suggest a third floating-point format (%g maybe, or something else if that is already taken) which would mean either %f or %e depending on the size of the exponent similar, IIRC, to the number output formats available in FORTRAN and/or BASIC. That format would be implicit when :echoing a floating-point number. (Yes, I know, Vim is neither FORTRAN nor BASIC, but I feel this kind of thing would be better than crashing or even than giving an error.) IIRC, in FORTRAN, the G output format would give (for different values output under a single format) results like: -1.234567E-123 (for a small number) 2.25 (with spaces to the same width) 342.5682 (with spaces for a large number but not too large) 6.02E+023 (for an even bigger number) NAN(a special case) -INF (another special case) (this from what [I think that] I remember from the time I used FORTRAN on computers whose printers had no lowercase letters). Best regards, Tony. -- MESKIMEN'S LAW There's never time to do it right, but always time to do it over. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On Thu 10-Apr-08 4:09am -0600, François Ingelrest wrote: On Thu, Apr 10, 2008 at 10:29 AM, Bill McCarthy [EMAIL PROTECTED] wrote: Thanks John, I was hoping that I didn't need to modify source code to accomplish it. Isn't there a way to add something to the make line? You could just pass -DFEAT_FLOAT to gcc if you don't want to modify the code. Thanks François, I didn't know it was called FEAT_FLOAT. Still, it would better if something could be added to the make command. -- Best regards, Bill --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 10/04/08 10:29, Bill McCarthy wrote: On Thu 10-Apr-08 3:14am -0600, John Beckett wrote: Bill McCarthy wrote: I want +float - how do I make that happen? One simple method is to add the following line to src/feature.h #define FEAT_FLOAT You could probably do that anywhere, but just after the section with #if relating to FEAT_FLOAT is probably a good place. I would welcome a less crude suggestion. Thanks John, I was hoping that I didn't need to modify source code to accomplish it. Isn't there a way to add something to the make line? I built a Huge version with the patch (I think Normal would have been enough) and got +float. There was an error message from the configure step at first, and I had to remove src/auto/config.cache then it worked. To avoid losing the ability to compile Vim without the patch, I used first cd ../.. mkdir -v vim-test cp -av vim/* vim-test FEAT_FLOAT is defined at line 384 of feature.h if you are building a Normal or Huge build and FEAT_POW is defined. I think the latter is defined by configure if it finds out that your C compiler knows about the pow() function -- here are two possibly relevant lines from the output of configure, with 3 context lines above and below (lines 344-351 in all): checking whether stat() ignores a trailing slash... no checking for iconv_open()... yes checking for nl_langinfo(CODESET)... yes checking for pow in -lm... yes checking for pow()... yes checking --disable-acl argument... no checking for acl_get_file in -lposix1e... no checking for acl_get_file in -lacl... yes I applied no modifications to the source code for floating point (I modified float.h but only to enable +xterm_save and disable +tag_old_static). My configure options are set by having bash source (not run) the following script before running make (watch out for spurious linebreaks possibly added by your mailer or by mine): #!/bin/bash export CONF_OPT_GUI='--enable-gnome-check' export CONF_OPT_PERL='--enable-perlinterp' export CONF_OPT_PYTHON='--enable-pythoninterp' export CONF_OPT_TCL='--enable-tclinterp --with-tcl=tclsh8.4' export CONF_OPT_RUBY='--enable-rubyinterp' export CONF_OPT_MZSCHEME='--disable-mzschemeinterp' #export CONF_OPT_PLTHOME='--with-plthome=/usr/local/plt' export CONF_OPT_CSCOPE='--enable-cscope' export CONF_OPT_MULTIBYTE='--enable-multibyte' export CONF_OPT_FEAT='--with-features=huge' export CONF_OPT_COMPBY='[EMAIL PROTECTED]' # need to patch feature.h # to disable +tag_old_static: comment out: # # define FEAT_TAG_OLDSTATIC # at line 360 (or about) # to enable +xterm_save: uncomment: # /* #define FEAT_XTERM_SAVE */ # at line 831 (or about) export CONF_ARGS='--with-modified-by=Bram Moolenaar (floating point)' Best regards, Tony. -- Paranoids are people, too; they have their own problems. It's easy to criticize, but if everybody hated you, you'd be paranoid too. -- D. J. Hicks --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
RE: Patch to try out: floating point
Bill McCarthy wrote: I think the correct way to pass the requested feature without editing feature.h is: make DEFS=-DFEAT_FLOAT Thanks John but that didn't work here... If you're using Make_mvc.mak, the command is: nmake -f Make_mvc.mak DEFINES=-DFEAT_FLOAT Looking at the make file, it seems your trick of adding it to FEATURES would work fine as well, but the above is what's suggested in the make file. To get HUGE you would use: nmake -f Make_mvc.mak FEATURES=HUGE DEFINES=-DFEAT_FLOAT John --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
How many people actually do that? Should they be doing that? IMHO I'd force people to use whitespace for concatenation in this case (i.e. 123 . 456) and have 123.456 be a floating point number. That's how Perl works, for example. --Antony That would break compatibility on much, much, much larger scale than changes in regexp engine suggested few weeks ago. The only full solution to that problem would be total transition: Start now discussion about future changes, suggested implementations, features, etc. Announce Vim 8 as transition period and start porting existing scripts to new goals without making real changes to engine. Break compatibility with Vim 9. Such transition would take 3-4 years and it is reasonable that all interested parties would port scripts. But I am not sure if it is worth it. Just one thought: Perl 6. m. Nowa komedia twórców Dziennika Bridget Jones i To własnie miłość! Film NA PEWNO, BYĆ MOŻE - w kinach już od 11 kwietnia. http://klik.wp.pl/?adr=http%3A%2F%2Fcorto.www.wp.pl%2Fas%2Fzwiastun.htmlsid=306 --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Le Tue, 08 Apr 2008 22:45:18 +0200, Bram Moolenaar a écrit dans le message [EMAIL PROTECTED] : One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. Thanks Bram. Using Windows98, gVim 7.1.291 and Borland C++ 5.5.1 I have : - A compiler warning: Warning W8065 .\eval.c 7289: Call to function 'pow' with no prototype in function string2float - Strange results: :echo 1.5 * 1.609344 1.0762210 :echo 1500 * 1609 :2413500 I added to my make_bc5.mak: === make_bc5.mak !if ($(FLOAT)==) FLOAT = yes !endif !if ($(FLOAT)==yes) DEFINES = $(DEFINES) -DFEAT_FLOAT !endif = :version returns: +arabic +autocmd +balloon_eval +browse ++builtin_terms +byte_offset +cindent +clientserver +clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +cryptv +cscope +cursorshape +dialog_con_gui +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +gettext/dyn -hangul_input +iconv/dyn +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap +menu +mksession +modify_fname +mouse +mouseshape +multi_byte_ime/dyn +multi_lang -mzscheme +netbeans_intg +ole -osfiletype +path_extra +perl/dyn -postscript +printer +profile -python +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl -tgetent -termresponse +textobjects +title +toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup -xfontset -xim -xterm_save -xpm_w32 fichier vimrc système : $VIM\vimrc fichier vimrc utilisateur : $HOME\_vimrc 2me fichier vimrc utilisateur : $VIM\_vimrc fichier exrc utilisateur : $HOME\_exrc 2me fichier exrc utilisateur : $VIM\_exrc fichier gvimrc système : $VIM\gvimrc fichier gvimrc utilisateur : $HOME\_gvimrc 2me fichier gvimrc utilisateur : $VIM\_gvimrc fichier menu système : $VIMRUNTIME\menu.vim Compilation : c:\borland\bcc55\BIN\Bcc32 -w-aus -w-par -w-pch -w-ngu -w-csu -Ic:\perl\lib\core;c:\borland\bcc55\include;.;p roto -d -RT- -k- -Oi -H -H=vim.csm -Hc -f- -DFEAT_HUGE -DWIN32 -DHAVE_PATHDEF -DWINVER=0x0400 -D_WIN32_WINNT=0x0400 -DFEAT_OLE -DFEAT_FLOAT -DFEAT_CSCOPE -DFEAT_GUI_W32 -DFEAT_CLIPBOARD -DFEAT_NETBEANS_INTG -DFEAT_MBYTE -DFEAT_MBYTE_IME -DDYNAMIC_IME -DDYNAMIC_ICONV -DDYNAMIC_GETTEXT -DFEAT_PERL -DDYNAMIC_PERL -DDYNAMIC_PERL_DLL=\perl58.dll\ -O2 -f- -d -Ocavi -O -vi- -W -5 -a4 Édition de liens : c:\borland\bcc55\BIN\ILink32 -OS -Tpe -c -m -Lc:\borland\bcc55\lib -aa -- Patrick Texier, Frulon, 36190 Orsennes, France (46°31'N, 01°41'E) http://www.genindre.org http://www.genindre.org/cgi-bin/geneweb.cgi?b=pt --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Patrick Texier wrote: Le Tue, 08 Apr 2008 22:45:18 +0200, Bram Moolenaar a écrit dans le message [EMAIL PROTECTED] : One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. Thanks Bram. Using Windows98, gVim 7.1.291 and Borland C++ 5.5.1 I have : - A compiler warning: Warning W8065 .\eval.c 7289: Call to function 'pow' with no prototype in function string2float You should #define HAVE_MATH_H in os_win32.h. - Strange results: :echo 1.5 * 1.609344 1.0762210 I get 2.414016. Perhaps this is caused by the problem with pow()? :echo 1500 * 1609 :2413500 I added to my make_bc5.mak: === make_bc5.mak !if ($(FLOAT)==) FLOAT = yes !endif !if ($(FLOAT)==yes) DEFINES = $(DEFINES) -DFEAT_FLOAT !endif = Should not be needed, since FEAT_FLOAT is defined when FEAT_EVAL is defined and HAVE_MATH_H. So you need to change os_win32.h as mentioned above. -- hundred-and-one symptoms of being an internet addict: 260. Co-workers have to E-mail you about the fire alarm to get you out of the building. /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\download, build and distribute -- http://www.A-A-P.org/// \\\help me help AIDS victims -- http://ICCF-Holland.org/// --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
RE: Patch to try out: floating point
Bram Moolenaar wrote: Now the patch is attached, hopefully that works better. The file diff.dat that you just attached, and your earlier inline mail are the same. In both cases, there is a problem: the last 12 lines should be omitted (you can see they are a slightly broken duplicate of the just-preceding lines). ---start omit (last 12 lines)--- +** ../vim-7.1.291/src/version.cTue Apr 1 20:58:23 2008 --- src/version.c Sun Apr 6 15:25:42 2008 ** -find_in_path, #endif + #ifdef FEAT_FLOAT + +float, + #else + -float, + #endif #ifdef FEAT_FOLDING +folding, ---end omit--- For the record, Tony's attached patch correctly omitted the above 12 lines, but Tony's patch has a problem in the middle: ---instead of--- + f + #ifndef HAVE_STDARG_H ---should be--- + f = + #ifndef HAVE_STDARG_H ---end--- I have built and run Vim with the patch (as corrected above). It patched and built with no problems. A very quick test correctly executed the following (showing result 12.99): :echo 1.23 + 11.76 It will be a while before I can think of anything to do with floating point in an editor, but no doubt someone will explain it to me. John --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 09/04/2008, Bram Moolenaar [EMAIL PROTECTED] wrote: Antony Scriven wrote: On 08/04/2008, Bram Moolenaar [EMAIL PROTECTED] wrote: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 [...] How many people actually do that? Should they be doing that? IMHO I'd force people to use whitespace for concatenation in this case (i.e. 123 . 456) and have 123.456 be a floating point number. That's how Perl works, for example. --Antony Search in existing scripts and you will find examples of doing string concatenation like this. I don't want to break existing scripts in some obscure way. Okay, but I meant that spaces should be required just for numbers. I bet those examples are harder to find in existing scripts, if they exist at all. Why would anyone put 1.2 in a script in favour of '12'? --Antony --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Hi, Bram Moolenaar wrote: Antony Scriven wrote: On 08/04/2008, Bram Moolenaar [EMAIL PROTECTED] wrote: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 [...] How many people actually do that? Should they be doing that? IMHO I'd force people to use whitespace for concatenation in this case (i.e. 123 . 456) and have 123.456 be a floating point number. That's how Perl works, for example. --Antony Search in existing scripts and you will find examples of doing string concatenation like this. I don't want to break existing scripts in some obscure way. what about a command similar to scriptencoding which would enable support for floating point numbers in this particular script? Or just allows to write them without the need to use a marker? Marked floating point numbers would then always be allowed. IMHO, scripts that use a dot to concatenate literal numbers deserve to be broken. The only reason I could think of is to (ab-)use Vim's conversion from octal to decimal as in :echo 123.0456 which results in 123302 -- a rather obscure way to generate this output. I strongly think Vim should use the same format for literal floating point numbers that most other languages use. Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin) --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 09/04/08 12:34, John Beckett wrote: Bram Moolenaar wrote: Now the patch is attached, hopefully that works better. The file diff.dat that you just attached, and your earlier inline mail are the same. In both cases, there is a problem: the last 12 lines should be omitted (you can see they are a slightly broken duplicate of the just-preceding lines). ---start omit (last 12 lines)--- +** ../vim-7.1.291/src/version.c Tue Apr 1 20:58:23 2008 --- src/version.c Sun Apr 6 15:25:42 2008 ** -find_in_path, #endif + #ifdef FEAT_FLOAT + +float, + #else + -float, + #endif #ifdef FEAT_FOLDING +folding, ---end omit--- For the record, Tony's attached patch correctly omitted the above 12 lines, but Tony's patch has a problem in the middle: ---instead of--- + f + #ifndef HAVE_STDARG_H ---should be--- + f = + #ifndef HAVE_STDARG_H ---end--- I have built and run Vim with the patch (as corrected above). It patched and built with no problems. A very quick test correctly executed the following (showing result 12.99): :echo1.23 +11.76 It will be a while before I can think of anything to do with floating point in an editor, but no doubt someone will explain it to me. John 12 extra lines at the end shouldn't be a problem, since the patch program will ignore garbage before and after the patch proper. I know what to do with floating point in an editor: use it as a cheap calculator program without the need to scale for digits right of the decimal point. Maybe other things too. (cheap because the marginal cost of the calculator is nil, since I need the editor anyway.) Best regards, Tony. -- At least they're _EXPERIENCED_ incompetents --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 09/04/08 11:30, Bram Moolenaar wrote: [...] Now the patch is attached, hopefully that works better. Patch went OK this time -- except for the helpfile, but that was expected: patches for runtime files are always flaky, and it won't change anything to the binary. Added a --with-modified-by=Bram Moolenaar (floating point) argument (via $CONF_ARGS) and started make reconfig on a Huge build. It compiles and :version says +float -- I'll post the full :version output at http://users.skynet.be/antoine.mechelynck/vim/version.txt (reformatted to 80 characters for readability). Let's do a few tests... Oh, oh.. it had started working (and 1.0e256 multiplied by itself gives inf, which is correct), but :echo 1.0e308 crashes gvim (on Linux i686) with SIGSEGV. And BTW -- I found one oversight in the helpfile patch: runtime/doc/eval.txt, line 40 is unchanged, there is: There are five types of variables: There should be: There are six types of variables: Best regards, Tony. -- Justice is incidental to law and order. -- J. Edgar Hoover --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On Wed, Apr 9, 2008 at 7:01 AM, Jürgen Krämer [EMAIL PROTECTED] wrote: Bram Moolenaar wrote: Antony Scriven wrote: On 08/04/2008, Bram Moolenaar [EMAIL PROTECTED] wrote: The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 [...] How many people actually do that? Should they be doing that? IMHO I'd force people to use whitespace for concatenation in this case (i.e. 123 . 456) and have 123.456 be a floating point number. That's how Perl works, for example. --Antony Search in existing scripts and you will find examples of doing string concatenation like this. I don't want to break existing scripts in some obscure way. what about a command similar to scriptencoding which would enable support for floating point numbers in this particular script? Or just allows to write them without the need to use a marker? Marked floating point numbers would then always be allowed. I like this suggestion. A mechanism that allows a script writer to declare a script as one that uses unmarked floating point numbers would be a good compromise. It would allow old scripts to remain unchanged even if they use a dot to concatenate literal numbers. Most authors of new scripts that use floating point numbers would find one added command/setting per script a small price to pay for being able to use standard notation for floating point numbers. Ajit --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 09/04/08 14:51, Ajit Thakkar wrote: On Wed, Apr 9, 2008 at 7:01 AM, Jürgen Krämer[EMAIL PROTECTED] wrote: Bram Moolenaar wrote: Antony Scriven wrote: On 08/04/2008, Bram Moolenaar[EMAIL PROTECTED] wrote: The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 [...] How many people actually do that? Should they be doing that? IMHO I'd force people to use whitespace for concatenation in this case (i.e. 123 . 456) and have 123.456 be a floating point number. That's how Perl works, for example. --Antony Search in existing scripts and you will find examples of doing string concatenation like this. I don't want to break existing scripts in some obscure way. what about a command similar to scriptencoding which would enable support for floating point numbers in this particular script? Or just allows to write them without the need to use a marker? Marked floating point numbers would then always be allowed. I like this suggestion. A mechanism that allows a script writer to declare a script as one that uses unmarked floating point numbers would be a good compromise. It would allow old scripts to remain unchanged even if they use a dot to concatenate literal numbers. Most authors of new scripts that use floating point numbers would find one added command/setting per script a small price to pay for being able to use standard notation for floating point numbers. Ajit I'm not sure this would be productive in the long run: you would still have to type the when entering floating-point literals at the command line, so that script-only command would get in the way of learning true Vim floating-point language, the way mswin.vim gets in the way of learning true normal-mode commands. Once you'll have learnt that, in Vim, floating-point literals are distinguished by an prefix (and MUST be typed that way at the keyboard), it will feel normal to write them the same way in scripts. OTOH, when you use :scriptencoding latin1 in a script created while 'encoding ' is set to UTF-8, you still type é (e-acute) as é, it is entered into memory as a UTF-8 é, translated to a Latin1 é when the script is saved to disk, read back with no translation when sourced and correctly interpreted as é after the :scriptencoding command, but you never see it as anything else than é. Similarly for any other letter. How many times will we have to repeat: Vim is not Notepad, Vim is not Emacs, Vim is not BASIC and Vim is not C. Don't try to force it to behave as one of them, that's not how it works. Best regards, Tony. -- Newlan's Truism: An acceptable level of unemployment means that the government economist to whom it is acceptable still has a job. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
2008/4/8 Mikolaj Machowski [EMAIL PROTECTED]: Dnia Tuesday 08 of April 2008, Bram Moolenaar napisał: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. Thanks. Should simplify some things. Please enlighten me, because I don't see the use case for floating point values in a text editor. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Hi, 2008/4/9 Nikolai Weibull [EMAIL PROTECTED]: 2008/4/8 Mikolaj Machowski [EMAIL PROTECTED]: Dnia Tuesday 08 of April 2008, Bram Moolenaar napisał: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. Thanks. Should simplify some things. Please enlighten me, because I don't see the use case for floating point values in a text editor. I agree. There are too many items in the todo list waiting to be incorporated or fixed in Vim. These are all related to text editing. IMHO, I don't see the support for floating point numbers useful to editing text. As Bram once said, we should not add a feature to Vim just because somebody might use it someday. - Yegappan --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Yegappan Lakshmanan wrote: 2008/4/9 Nikolai Weibull [EMAIL PROTECTED]: 2008/4/8 Mikolaj Machowski [EMAIL PROTECTED]: Dnia Tuesday 08 of April 2008, Bram Moolenaar napisa³: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. Thanks. Should simplify some things. Please enlighten me, because I don't see the use case for floating point values in a text editor. I agree. There are too many items in the todo list waiting to be incorporated or fixed in Vim. These are all related to text editing. IMHO, I don't see the support for floating point numbers useful to editing text. As Bram once said, we should not add a feature to Vim just because somebody might use it someday. A floating point number an appear in the text. One might want to edit it. I agree the use is limited, but implementation is not much work. I need it myself for adding up a list of numbers and currency conversion. Of course it's possible to use :python or external tools for that. -- hundred-and-one symptoms of being an internet addict: 10E. You start counting in hex. /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\download, build and distribute -- http://www.A-A-P.org/// \\\help me help AIDS victims -- http://ICCF-Holland.org/// --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Dnia Wednesday 09 of April 2008, Nikolai Weibull napisał: 2008/4/8 Mikolaj Machowski [EMAIL PROTECTED]: Dnia Tuesday 08 of April 2008, Bram Moolenaar napisał: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. Thanks. Should simplify some things. Please enlighten me, because I don't see the use case for floating point values in a text editor. Calculation of percentages in few scripts. Automatic filling of data in CSVs. No need to start separate calculator - or hunt separate device in office - when writing something (eg. calculate price + VAT: x*1.22) m. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Dnia Wednesday 09 of April 2008, Bram Moolenaar napisał: Now the patch is attached, hopefully that works better. Thanks, this one is working. One bug: :echo 1.90+90 280,00 :echo 1.90-90 100,00 OK, but :echo 1.90*90 E806: using Float as a String E15: Illegal expression: 1.90*90 :echo 1.90/90 E806: using Float as a String E15: Illegal expression: 1.90/90 These two: :echo 1.90*90 :echo 1.90/90 Work. What about slightly more verbose solution? Make float() not reduced to one variable but as environment where *all* variables are treated as float but outside of that are treated as strings. Example: :let a = float(2/4) :echo a 0.5 :let b = a . +5 :echo b 0.5+5 :let c = float(a . +5) :echo c 5.5 m. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 09/04/2008 17:27, Mike Williams wrote: On 09/04/2008 17:16, Bram Moolenaar wrote: Francois Ingelrest wrote: On Wed, Apr 9, 2008 at 5:30 PM, Bram Moolenaar [EMAIL PROTECTED] wrote: Easy to reproduce. Turns out that this line causes it: sprintf(tmp, format, f); Here format is %f and f is your value 1e+308. The result is an awful long string of numbers. I suppose it's about 308 digits. How big does tmp need to be to hold any result here? I don't think %f has a way of specifying a maximal field width. You could use snprintf() to specify the maximum length of tmp. Unfortunately, snprintf() is not available everywhere, and the implementations are not always working in a portable way. The code actually is inside vim_snprintf(), which is the Vim implementation of snprintf(). But it still uses sprintf() to do the difficult work. I guess that 1e308 is about the largest number supported by double. At least for me 1e309 results in infinity. Would it be safe enough to use a buffer of about 350 chars? Or are there platforms where double can be much bigger? Intel FPU's have 80 bit reals supporting IEEE 754 double extended precision, with an absolute exponent range of 16384. And then there are 128 bit reals as well ... You have to draw the line somewhere ;-) Ugh, apologies, 16384 is the binary exponent value, this maps to (if my brain is working) a upper range limit of ~1x10^4932. For completeness IEEE 754 128 bit real has an upper range limit of ~1X10^6144. There are other fp representations with even greater range OK, so we do need to worry about this. This patch to message.c, replacing the previous one, should do it. - God made the integers; all else is the work of Man. -- Kronecker /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net \\\ ///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\download, build and distribute -- http://www.A-A-P.org/// \\\help me help AIDS victims -- http://ICCF-Holland.org/// --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~--- diff Description: Binary data
Re: Patch to try out: floating point
Dnia Wednesday 09 of April 2008, Tony Mechelynck napisał: runtime/doc/eval.txt, line 40 is unchanged, there is: There are five types of variables: There should be: There are six types of variables: One more addition to eval.txt, line 5218 (:help type()): :if type(myvar) == type({}) Add after that line: :if type(myvar) == type(0) m. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
RE: Patch to try out: floating point
Tony Mechelynck wrote: 12 extra lines at the end shouldn't be a problem, since the patch program will ignore garbage before and after the patch proper. I was just trying to let Bram know that it would look better if he fixed the patch (by deleting the last 12 lines), if he were planning to release it elsewhere. John --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
What's your opinion about a project in VIMas an on the fly code checker. Steps - i.That is VIM text to a temporary file. ii.Compile it with a compiler.(Either use an external compiler ( preferred by Mr. Moolenaar) or to write an independent parser plug-in within VIM) iii.Then re-parse the error messages. This is my proposed idea for Google Summer of Code 2008. Is there any mistake or faults.Please guide me out. Please reply. Anoop Thomas Mathew [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On Tue, Apr 08, 2008 at 10:45:18PM +0200, Bram Moolenaar wrote: One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 That is because . is the concatenation operator, and numbers are automatically converted to strings. I considered a few alternatives: 123,456 used for function arguments float(123,456)too verbose #123.456has a meaning after == and != $123.456confusion with $ENV The best I could think of was 123.456. It's a bit obscure, you need to get used to it. But it works. echo 123.456e-3 0.123456 Feel free to suggest something better, but make sure it doesn't already mean something in any context in Vim script. How about just adding an f at the end of the number? echo 1.23f This doesn't seem to mean anything to Vim currently. (I get an error when I try and echo it). GI -- A)bort, R)etry, I)nfluence with large hammer. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On Tue, Apr 08, 2008 at 01:56:24PM -0700, Gautam Iyer wrote: One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 That is because . is the concatenation operator, and numbers are automatically converted to strings. I considered a few alternatives: 123,456 used for function arguments float(123,456)too verbose #123.456has a meaning after == and != $123.456confusion with $ENV The best I could think of was 123.456. It's a bit obscure, you need to get used to it. But it works. echo 123.456e-3 0.123456 Feel free to suggest something better, but make sure it doesn't already mean something in any context in Vim script. How about just adding an f at the end of the number? echo 1.23f This doesn't seem to mean anything to Vim currently. (I get an error when I try and echo it). I forgot to mention: Also echo 1.23e-3 can be used for the E notation. (The trailing f is not necessary). Oops. My bad. :set f=1 :echo 1.23f 123 1 GI -- Pentium of Borg: Division is futile - your decimals will be approximated. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Bram Moolenaar wrote: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. You just did that, so you can stay at home ? @-; [...] The best I could think of was 123.456. It's a bit obscure, you need to get used to it. But it works. echo 123.456e-3 0.123456 Feel free to suggest something better, but make sure it doesn't already mean something in any context in Vim script. Maybe you want to have bitoperator one day ? -ap --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Dnia Tuesday 08 of April 2008, Bram Moolenaar napisał: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. Thanks. Should simplify some things. echo 123.456e-3 0.123456 Feel free to suggest something better, but make sure it doesn't already mean something in any context in Vim script. Have fun with the patch! I thought immediately about 123;456 , looks like it doesn't create conflicts but is equally obscure as . *** ../vim-7.1.291/runtime/doc/eval.txt Wed Feb 20 20:09:44 2008 --- runtime/doc/eval.txt Tue Apr 8 22:19:37 2008 *** *** 39,49 *E712* Couldn't apply: [EMAIL PROTECTED] ~/vim7 $ patch -p0 --dry-run float.diff patch: malformed patch at line 5: *E712* GNU patch 2.5.9 Any ideas? TIA m. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Dnia Wednesday 09 of April 2008, Mikolaj Machowski napisał: Feel free to suggest something better, but make sure it doesn't already mean something in any context in Vim script. Have fun with the patch! I thought immediately about 123;456 , looks like it doesn't create conflicts but is equally obscure as . Sorry, may conflict with unpacking of lists: :help let-unpack m. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
Dnia Wednesday 09 of April 2008, Tony Mechelynck napisał: On 08/04/08 23:57, Mikolaj Machowski wrote: [...] Couldn't apply: [EMAIL PROTECTED] ~/vim7 $ patch -p0 --dry-run float.diff patch: malformed patch at line 5:*E712* GNU patch 2.5.9 Any ideas? TIA m. The patch was sent inline, and I (and maybe you) received it in quoted-printable format. I tried to fix it (see attachment): does it work? No. But for different reason: [EMAIL PROTECTED] ~/vim7 $ patch -p0 --dry-run float.diff missing header for context diff at line 3 of patch patching file runtime/doc/eval.txt Hunk #6 FAILED at 2058. 1 out of 13 hunks FAILED -- saving rejects to file runtime/doc/eval.txt.rej patching file src/auto/configure patching file src/config.h.in patching file src/configure.in patching file src/eval.c patching file src/feature.h patching file src/if_python.c patching file src/message.c patch: unexpected end of hunk at line 1704 Thanks, I will be able to test more only tomorrow evening. Good night :) m. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 09/04/08 00:34, Mikolaj Machowski wrote: Dnia Wednesday 09 of April 2008, Tony Mechelynck napisał: On 08/04/08 23:57, Mikolaj Machowski wrote: [...] Couldn't apply: [EMAIL PROTECTED] ~/vim7 $ patch -p0 --dry-run float.diff patch: malformed patch at line 5:*E712* GNU patch 2.5.9 Any ideas? TIA m. The patch was sent inline, and I (and maybe you) received it in quoted-printable format. I tried to fix it (see attachment): does it work? No. But for different reason: [EMAIL PROTECTED] ~/vim7 $ patch -p0 --dry-run float.diff missing header for context diff at line 3 of patch patching file runtime/doc/eval.txt Hunk #6 FAILED at 2058. 1 out of 13 hunks FAILED -- saving rejects to file runtime/doc/eval.txt.rej patching file src/auto/configure patching file src/config.h.in patching file src/configure.in patching file src/eval.c patching file src/feature.h patching file src/if_python.c patching file src/message.c patch: unexpected end of hunk at line 1704 Thanks, I will be able to test more only tomorrow evening. Good night :) m. I got the same thing. I believe there must be something wrong in Bram's patch for message.c -- there aren't the right number of added lines for the range given. Best regards, Tony. -- Yesterday is history. Tomorrow is a mystery. Today is a gift. That's why it is called 'present'. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 08/04/2008, Bram Moolenaar [EMAIL PROTECTED] wrote: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 [...] How many people actually do that? Should they be doing that? IMHO I'd force people to use whitespace for concatenation in this case (i.e. 123 . 456) and have 123.456 be a floating point number. That's how Perl works, for example. --Antony --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On 09/04/08 00:43, Antony Scriven wrote: On 08/04/2008, Bram Moolenaar[EMAIL PROTECTED] wrote: I have been preparing a talk for the upcoming FISL conference in Brazil: http://fisl.softwarelivre.org/9.0/www/ One of the items I planned to discuss is why Vim has no floating point support. Well, this turned into actually implementing it. The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 [...] How many people actually do that? Should they be doing that? IMHO I'd force people to use whitespace for concatenation in this case (i.e. 123 . 456) and have 123.456 be a floating point number. That's how Perl works, for example. --Antony I always use spaces around the concatenation operator, but I've seen many people using it with no spaces, and as you know, in Vim upward compatibility is primordial. This said, a quick glance at the code shows that it seems to use only a doubleword for floats -- doesn't the C language support a native float type (or even long float or something?), which would map to the IEEE datatypes used by e.g. the ix87 math coprocessor? If the hardware supports 10^-308 to 10^308, I wouldn't expect :echo 1.e-100 to return zero. Best regards, Tony. -- Sooner or later, generals will own you. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
... The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 That is because . is the concatenation operator, and numbers are automatically converted to strings. I considered a few alternatives: 123,456 used for function arguments float(123,456)too verbose #123.456has a meaning after == and != $123.456confusion with $ENV The best I could think of was 123.456. It's a bit obscure, you need to get used to it. But it works. echo 123.456e-3 0.123456 Feel free to suggest something better, but make sure it doesn't already mean something in any context in Vim script. Why not leave it as specifying e on the end of any floating point number. 123.456e-3 123.456e+0 And so on? That would prevent any confusion, unless of course that is already used. Dave --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---
Re: Patch to try out: floating point
On Tue, Apr 08, 2008 at 09:47:50PM -0400, David Fishburn wrote: The main problem with floating point is that the usual notation already has a meaning: echo 123.456 123456 That is because . is the concatenation operator, and numbers are automatically converted to strings. I considered a few alternatives: 123,456 used for function arguments float(123,456)too verbose #123.456has a meaning after == and != $123.456confusion with $ENV The best I could think of was 123.456. It's a bit obscure, you need to get used to it. But it works. echo 123.456e-3 0.123456 Feel free to suggest something better, but make sure it doesn't already mean something in any context in Vim script. Why not leave it as specifying e on the end of any floating point number. 123.456e-3 123.456e+0 And so on? That would prevent any confusion, unless of course that is already used. Already used: :let e=1 :echo 1.23e+0 123 1 I made the same mistake :) GI -- Shotgun wedding: A case of wife or death. --~--~-~--~~~---~--~~ You received this message from the vim_dev maillist. For more information, visit http://www.vim.org/maillist.php -~--~~~~--~~--~--~---