all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* RE: Code for converting between Elisp and Calc floats
@ 2009-10-27  4:56 Vincent Belaïche
  2009-10-27  6:16 ` Stefan Monnier
  0 siblings, 1 reply; 20+ messages in thread
From: Vincent Belaïche @ 2009-10-27  4:56 UTC (permalink / raw)
  To: monnier; +Cc: cyd, emacs-devel

[-- Attachment #1: Type: text/plain, Size: 3218 bytes --]














Hello Stefan,


> [SNIP]

> 
> I understand the code is simpler on the Lisp side, but I'm more
> concerned about the C side.  Of course, if the Lisp side becomes
> unmanageable it's also relevant.
>

For the C code anyhow, even if the integer component word size was not passed along in the interface, you would have anyhow to manage strange word sizes. This is because the mantissa is 53 bits, and 53 is not a multiple of 16. Also the mantissa is not aligned on the double word boundary (the sign + exponent not being a muliple of 16 bits) and
you also have this phantom bit case to handle.

I agree however that the C could have been slightly simpler if the integer component word size was forced to be 16bits.

Maybe we could add one more layer in Lisp that would encapsulate the C function and add the word lengths to be 16 for those who would like to use the builtin function for other purpose, but with a simpler interface. This would basically achieve the interface that you envisionned as far as I can understand. Calc would however not use this additional layer of code.


> [SNIP] 
> > This is the switch between the two types of implementations: the one
> > using builtin support, and the one not needing builtin support.
> 
> So (fboundp 'construct-float) would work as well?
>

Yes, definitely. That could be done this way, the  reason why I used a specific variable is more historical than rational.


> [SNIP] 
> I think it fits better in C. Basically, it would be the equivalent to
> C's frexp.

C++' frexp and ldexp are not a direct alternative, because the significand is still a non integer number (between 0.5 and 1 for frexp). So anyhow you would have to build clean powers of two to convert from the frexp returned significand to Calc internal mantissa that is an integer. Also the dynamic of the mantissa is higher than that of a Lisp integer, so any how you have so stick/split bits together/apart. However by combining calls to frexp, ldexp and floor one could get around.


Frankly speaking, I must admit that I ignored the existance of frexp and ldexp standard functions. If I had known about them, maybe I would have tried to write the builtin functions with using only frexp ldexp and stuff like _isnan and suhclikes to handle special cases. That would have come at the cost of a slight additional processing cost, but this is completely neglectable in the case of Calc, due to the overhead of Lisp.

Another alternative would be that frexp and ldexp and suhlikes are made builtin functions, and that the construct-float, deconstruct-float functions are in Lisp using those builtins: that would indeed be my preference if everyone thinks that the submitted C code is too complex. 


I am not sure however that re-coding those functions with frexp, ldexp and floor, would be that significantly less complex to justify the effort, now that I have already done the job in a more primitive way.

     Vincent.



 		 	   		  
_________________________________________________________________
Nouveau ! Tout Windows débarque dans votre téléphone. Voir les Windows phone
http://clk.atdmt.com/FRM/go/175819071/direct/01/

[-- Attachment #2: Type: text/html, Size: 3742 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread
* allow C-x v i / C-x v v to create a repository if none is available
@ 2009-10-08 20:47 Dan Nicolaescu
  2009-10-09 19:18 ` Stefan Monnier
  0 siblings, 1 reply; 20+ messages in thread
From: Dan Nicolaescu @ 2009-10-08 20:47 UTC (permalink / raw)
  To: emacs-devel


When doing C-x v i or C-x v v on an unregistered file that is in a
directory not under any version control, the file will be registered
with RCS.  That is not exactly what most users want.

The patch below asks the user what VC backend to use to create a
repository, it creates it and registers the file.

OK to check in?

Index: vc.el
===================================================================
RCS file: /cvsroot/emacs/emacs/lisp/vc.el,v
retrieving revision 1.732
diff -u -3 -p -u -p -r1.732 vc.el
--- vc.el	3 Oct 2009 18:29:26 -0000	1.732
+++ vc.el	8 Oct 2009 20:39:47 -0000
@@ -564,9 +564,6 @@
 ;;
 ;;;; Default Behavior:
 ;;
-;; - do not default to RCS anymore when the current directory is not
-;;   controlled by any VCS and the user does C-x v v
-;;
 ;; - vc-responsible-backend should not return RCS if no backend
 ;;   declares itself responsible.
 ;;
@@ -842,12 +840,31 @@ be registered."
 	(if (not register)
 	    ;; if this is not for registration, the first backend must do
 	    (car vc-handled-backends)
-	  ;; for registration, we need to find a new backend that
-	  ;; could register FILE
-	  (dolist (backend vc-handled-backends)
-	    (and (not (vc-call-backend backend 'registered file))
-		 (vc-call-backend backend 'could-register file)
-		 (throw 'found backend)))
+
+	  (if (file-directory-p file)
+	      (let* ((possible-backends
+		      (let (pos)
+			(dolist (crt vc-handled-backends)
+			  (when (vc-find-backend-function crt 'create-repo)
+			    (push crt pos)))
+			pos))
+		    (bk
+		     (intern
+		      (completing-read 
+		       (format "%s is not in a version controlled directory.\nWhat VC backend do you want to use to register: " file)
+		       (mapcar 'symbol-name possible-backends) nil t))))
+		;; FIXME: Maybe we need to let bound defauld-directory
+		;; around this call to make sure it runs in the right
+		;; place?
+		(vc-call-backend bk 'create-repo)
+		(throw 'found bk))
+	    ;; FIXME: Does this case ever happen?
+	    ;; for registration, we need to find a new backend that
+	    ;; could register FILE
+	    (dolist (backend vc-handled-backends)
+	      (and (not (vc-call-backend backend 'registered file))
+		   (vc-call-backend backend 'could-register file)
+		   (throw 'found backend))))
 	  (error "No backend that could register")))))
 
 (defun vc-expand-dirs (file-or-dir-list)
@@ -909,12 +930,12 @@ current buffer."
      ((and allow-unregistered (not (vc-registered buffer-file-name)))
       (if state-model-only-files
 	  (list (vc-responsible-backend
-		 (file-name-directory (buffer-file-name)))
+		 (file-name-directory (buffer-file-name)) t)
 		(list buffer-file-name)
 		(list buffer-file-name)
 		(when state-model-only-files 'unregistered)
 		nil)
 	(list (vc-responsible-backend
-	       (file-name-directory (buffer-file-name)))
+	       (file-name-directory (buffer-file-name)) t)
 	      (list buffer-file-name))))
      (t (error "No fileset is available here")))))




^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2009-10-27 19:38 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-27  4:56 Code for converting between Elisp and Calc floats Vincent Belaïche
2009-10-27  6:16 ` Stefan Monnier
2009-10-27 19:38   ` Vincent Belaïche
  -- strict thread matches above, loose matches on Subject: below --
2009-10-08 20:47 allow C-x v i / C-x v v to create a repository if none is available Dan Nicolaescu
2009-10-09 19:18 ` Stefan Monnier
2009-10-22 18:56   ` Code for converting between Elisp and Calc floats Jay Belanger
2009-10-22 20:04     ` James Cloos
2009-10-23  0:50     ` Stefan Monnier
2009-10-24 20:03       ` Jay Belanger
2009-10-25  0:56         ` Stefan Monnier
2009-10-25  5:36           ` David Kastrup
2009-10-25 11:36             ` Vincent Belaïche
2009-10-25 14:11               ` Chong Yidong
2009-10-25 19:29                 ` Vincent Belaïche
2009-10-26  2:30                   ` Stefan Monnier
2009-10-26 12:48                     ` Vincent Belaïche
2009-10-27  3:22                       ` Stefan Monnier
2009-10-25 13:57             ` Stefan Monnier
2009-10-25 18:35               ` Eli Zaretskii
2009-10-23 13:11     ` Richard Stallman
2009-10-23 13:26       ` David Kastrup
2009-10-24 17:34         ` Richard Stallman

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.