@@ -3692,7 +3692,7 @@ def apply_name(self, name, evaluation):
36923692
36933693
36943694class Compress (Builtin ):
3695- """
3695+ u """
36963696 <dl>
36973697 <dt>'Compress[$expr$]'
36983698 <dd>gives a compressed string representation of $expr$.
@@ -4800,7 +4800,6 @@ def apply(self, pathname, evaluation):
48004800 return SymbolTrue
48014801 return SymbolFalse
48024802
4803-
48044803class Needs (Builtin ):
48054804 """
48064805 <dl>
@@ -4912,18 +4911,34 @@ class Needs(Builtin):
49124911 }
49134912
49144913 def apply (self , context , evaluation ):
4915- "Needs[context_String]"
4916-
4917- if not valid_context_name (context .get_string_value ()):
4918- evaluation .message ("Needs" , "ctx" , Expression ("Needs" , context ), 1 , "`" )
4914+ 'Needs[context_String]'
4915+ contextstr = context .get_string_value ()
4916+ if contextstr == "" :
4917+ return SymbolNull
4918+ if contextstr [0 ]== "`" :
4919+ curr_ctxt = evaluation .definitions .get_current_context ()
4920+ contextstr = curr_ctxt + contextstr [1 :]
4921+ context = String (contextstr )
4922+
4923+ if not valid_context_name (contextstr ):
4924+ evaluation .message ('Needs' , 'ctx' , Expression (
4925+ 'Needs' , context ), 1 , '`' )
49194926 return
49204927 test_loaded = Expression ("MemberQ" , Symbol ("$Packages" ), context )
49214928 test_loaded = test_loaded .evaluate (evaluation )
49224929 if test_loaded .is_true ():
49234930 # Already loaded
49244931 return SymbolNull
49254932
4926- result = Expression ("Get" , context ).evaluate (evaluation )
4933+ # TODO: Look why this rises the message
4934+ # "Select::normal: Nonatomic expression expected."
4935+ already_loaded = Expression ('MemberQ' ,
4936+ Symbol ('System`$Packages' ), context )
4937+ already_loaded = already_loaded .evaluate (evaluation ).is_true ()
4938+ if already_loaded :
4939+ return SymbolNull
4940+
4941+ result = Expression ('Get' , context ).evaluate (evaluation )
49274942
49284943 if result == Symbol ("$Failed" ):
49294944 evaluation .message ("Needs" , "nocont" , context )
0 commit comments