Relative path for require does not works as i expect

i have a file path1/file.rkt where i have this:

(include "../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/Scheme+.rkt")

in path2/Scheme+.rkt file i a have:

(require "overload.scm"). ;; i also tried "./overload.scm"

overload.scm is in the same path2 directory than Scheme+.rkt

but then at execution overload.scm is searched not in path2 but in path1 and in system module directory too is suppose, and it can find it and issue an error

why 'require' does not behave as 'include' ? why does not search in the path1 directory where Scheme+.rkt is as it is required from this place?

for this reason i forced to require my project files one by one instead of having an include that required all in it.

note:i searched many solution but can not find one, even if i can succeed in requiring it relatively than the definition will be unknown from the other file definitions (but i erased this solution, so i can not describe it to be reproducible)

I think the top-level TL;DR here is this: use require. Don't use include.

But I realize that without an explanation, that just sounds pushy and rude.

The documentation for include indicates that the source syntax for the given file is substituted for the use of include. This means that your path1/file.rkt now literally includes (require "overload.scm") This means that the expander will now look in the current directory for "overload.scm", rather than in path2.

What you wanted here, if I understand correctly, was that the syntax from Scheme+.rkt would "remember" where it was from, and look in that path.

The way to get what you want, I claim, is for you to use require in both places.

Specifically, your first file, path1/file.rkt should simply include

(require Scheme+)

Note that there is no path, no file ending, and no quotes. It's just telling racket to import the main.rkt file from the Scheme+ package.

But wait! How is racket supposed to know where the Scheme+ package lives? Well, you should tell it. More specifically, you should create a directory called Scheme+, put the Scheme+.rkt file in that directory (but name it main.rkt), then run

raco pkg install --link path/to/Scheme+

After this, your package should be in your local catalog, and you should be able to require the Scheme+ library as above.

You may be interested in this part of the documentation:

https://docs.racket-lang.org/guide/module-basics.html#(part._packages-and-collections)

I would start with the sentence that says: "The best option, however, is to add a package."

Hope this helps?

in the past Scheme+ was a module/package ,no more now.

i perheaps bad explained, the problem,about the error, it can. not be found overload.scm.

About package, all was in package, but it is quite impossible to do infix, with precedence, and WITH overload without knowing from each procedure used in scheme+, precedence procedure, infix procedure, how the overloaded procedure had became. That is the + operator existing at the beginning of Scheme+ loading is not the same after being overloaded and then the infix procedure and precedence must know it... i have not other solution but (include files) progrssively, example:

(provide (all-defined-out)) 

(require srfi/42) ; Eager Comprehensions

(require "matrix.rkt")

(require "matrix-by-vectors.rkt")

(require "../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/overload.scm")

(include "../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/Scheme+.rkt")

(include "../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/assignment.rkt") ; all sort ofassignment with <- 
(include "../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/apply-square-brackets.rkt") ; all sort of indexing with [] 


; first stage overloading
(define-overload-existing-operator +)
(define-overload-existing-operator *)
(define-overload-procedure uniform)

; to take in account the new overloaded operators scheme-infix.rkt must be included
; after the overloading first stage definition of operators
(include "../Scheme-PLUS-for-Racket/main/Scheme-PLUS-for-Racket/scheme-infix.rkt") ; add operator precedence to infix notation


; second stage overloading
(overload-existing-operator + vector-append (vector? vector?))

(overload-existing-operator * multiply-flomat-vector (flomat? vector?))

;; return a number in ]-1,1[
;; the dummy parameter is needed by a flomat procedure
(define (uniform-dummy dummy) {(random) * (if {(random 2) = 0} ; we randomly choose the sign of the random number
		         		1
			        	-1)})

; return a random number between [inf, sup]
(define (uniform-interval inf sup)
  {gap <+ {sup - inf}}
  {inf + gap * (random)}) ;; operator precedence ,* over +,is used in this expression

(overload-procedure uniform uniform-dummy (number?))

(overload-procedure uniform uniform-interval (number? number?))


; sigmoïde
(define (σ z̃) 
  {1 / {1 + (exp (- z̃))}})

; some derivatives

i can not find a way in Racket to "share" a module definition, for example share the infixe precedence operator list:

;; a list of lists of operators. lists are evaluated in order, so this also
;; determines operator precedence
;;  added bitwise operator with the associated precedences and modulo too
(define infix-operators-lst
  
  ;;'()
  
  (list
   
   (list expt **)
   (list * / %)
   (list + -)
   
   (list << >>)

   (list & ∣ )

  					; now this is interesting: because scheme is dynamically typed, we aren't
  					; limited to any one type of function
   
   (list < > = <> ≠ <= >=)
    
   ;;(list 'dummy) ;; can keep the good order in case of non left-right assocciative operators.(odd? reverse them) 
   
   )

  )

but note that overload.scm MUST be a module/package , i faced the case of infinite recursion due to have overloaded a procedure used in the included definitions of overload.scm (examle : overload 'length' but 'length' was used in overload procedure causing endless search in the overloaded method)

i admit this seems ugly to be forced to include some files in main file instead of requiring them but the result is good and it keep hygiene too and all is R*RS compliant, here is a few examples of what can be done:

(for ([i (in-range {n - 2})]) 
		     ;; create an array with 1 in front for the bias coefficient	    
		     {z_1 <- #(1) + z[i]} ; + operator has been overloaded to append scheme vectors

		     {z̃[i + 1] <- M[i] * z_1} ; z̃ = matrix * vector , return a vector

		     {z[i + 1] <- vector-map(activation_function_hidden_layer z̃[i + 1])}

		  ) ; end for


; modify coefficients layer
	(define (modification_des_poids M_i_o η z_input z_output z̃_output ᐁ_i_o მzⳆმz̃) ; derivative of activation function of the layer
	 
	  ; the length of output and input layer with coeff. used for bias update
	  {(len_layer_output len_layer_input_plus1forBias) <+ (dim M_i_o)} ; use values and define-values to create bindings
        
	  {len_layer_input <+ {len_layer_input_plus1forBias - 1}}

	  (for ([j (in-range len_layer_output)]) ; line
		
		(for ([i (in-range len_layer_input)]) ; column , parcours les colonnes de la ligne sauf le bias
		    
		    {M_i_o[j {i + 1}]  <-  M_i_o[j {i + 1}] - {(- η) * z_input[i] * მzⳆმz̃(z_output[j] z̃_output[j]) * ᐁ_i_o[j]}})

	; and update the bias
       {M_i_o[j 0]  <-  M_i_o[j 0] - {(- η) * 1.0 * მzⳆმz̃(z_output[j] z̃_output[j]) * ᐁ_i_o[j]}}))
	

moreover , the ,index operator as in Python and C++ can be overloaded dynamically, it is the procedure bracketapply in SRFI 105 curly infix and this variable MUST be known from top-level , the reader transform the syntax from curly infix to prefix,making bracketapply appear, so things can be in module but must be shared.

the data structure used in 'bracketapply' is overloaded,example:

>  (overload-square-brackets matrix-vect-ref
	 matrix-vect-set!  (matrix-vect? number? number?))
>  (overload-square-brackets matrix-vect-line-ref
	 (lambda (x) '())  (matrix-vect? number?))
> (define Mv (matrix-vect #(#(1 2 3) #(4 5 6))))
> $ovrld-square-brackets-lst$
'(((#<procedure:matrix-vect?> #<procedure:number?>) (#<procedure:matrix-vect-line-ref> . #<procedure>))
  ((#<procedure:matrix-vect?> #<procedure:number?> #<procedure:number?>) (#<procedure:matrix-vect-ref> . #<procedure:matrix-vect-set!>)))
> {Mv[1]}
'#(4 5 6)
> {Mv[1][0]}
4
> {Mv[1 0]}
4

in the previous example this allow two possibility of indexing a 2 dimension object: array[i1 i2] (like Python NumPy ) and array[i1][i2] (like Python), it then become:

 {M_i_o[j][i + 1]  <-  M_i_o[j] [i + 1] - {(- η) * z_input[i] * მzⳆმz̃(z_output[j] z̃_output[j]) * ᐁ_i_o[j]}})

i can not find a solution in Racket, the Guile port of code allow that.

I think the include-at/relative-to form will allow you to make this work.

i can find the doc :
https://docs.racket-lang.org/reference/include.html#(form._((lib._racket%2Finclude..rkt)._include-at%2Frelative-to))

but not an example

what is context? in doc